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
|
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
7f06cb8ceff3f2515f01662622e3c5149bcb8646
|
xm/main.py
|
xm/main.py
|
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'project', metavar='project', type=str, nargs='+',
help='The selected project',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
|
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-t', '--target', help='the target on which to run'
)
parser.add_argument(
'extra', metavar='extra', type=str, nargs='*',
help='Extra variables, usage vary depending on the context',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
|
Add a --target argument and make trailling arguments context dependant
|
Add a --target argument and make trailling arguments context dependant
|
Python
|
bsd-2-clause
|
pcadottemichaud/xm,pc-m/xm,pcadottemichaud/xm,pc-m/xm
|
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'project', metavar='project', type=str, nargs='+',
help='The selected project',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
Add a --target argument and make trailling arguments context dependant
|
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-t', '--target', help='the target on which to run'
)
parser.add_argument(
'extra', metavar='extra', type=str, nargs='*',
help='Extra variables, usage vary depending on the context',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
|
<commit_before>#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'project', metavar='project', type=str, nargs='+',
help='The selected project',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
<commit_msg>Add a --target argument and make trailling arguments context dependant<commit_after>
|
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-t', '--target', help='the target on which to run'
)
parser.add_argument(
'extra', metavar='extra', type=str, nargs='*',
help='Extra variables, usage vary depending on the context',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
|
#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'project', metavar='project', type=str, nargs='+',
help='The selected project',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
Add a --target argument and make trailling arguments context dependant#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-t', '--target', help='the target on which to run'
)
parser.add_argument(
'extra', metavar='extra', type=str, nargs='*',
help='Extra variables, usage vary depending on the context',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
|
<commit_before>#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'project', metavar='project', type=str, nargs='+',
help='The selected project',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
<commit_msg>Add a --target argument and make trailling arguments context dependant<commit_after>#!/usr/bin/env python2
# -*- coding: UTF-8 -*-
from __future__ import print_function
from __future__ import unicode_literals
import argparse
DEFAULT_CONFIG_FILE = '~/.config/xmrc'
def _new_argument_parser():
parser = argparse.ArgumentParser(
description='Build the appropriate make command'
)
parser.add_argument(
'-u', '--unittest', help='run unittest',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-s', '--sync', help='sync local copy on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-f', '--file', help='specify the configuration file',
default=DEFAULT_CONFIG_FILE,
)
parser.add_argument(
'--setup', help='run commands that should be run before sync',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-d', '--dep', help='install missing dependencies on the server',
action='store_const', const=True, default=False,
)
parser.add_argument(
'-t', '--target', help='the target on which to run'
)
parser.add_argument(
'extra', metavar='extra', type=str, nargs='*',
help='Extra variables, usage vary depending on the context',
)
return parser
def main():
parsed_args = _new_argument_parser().parse_args()
print(parsed_args)
if __name__ == '__main__':
main()
|
ab802204d84511765a701cad48e9e22dc4e84be1
|
tests/rules/conftest.py
|
tests/rules/conftest.py
|
import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True, scope="session")
def configured_cache():
cache.configure()
|
import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True)
def configured_cache():
if not cache.region.is_configured:
cache.configure()
yield
cache.region.invalidate()
|
Fix intermittent failures of test_guard_http_exception
|
Fix intermittent failures of test_guard_http_exception
Signed-off-by: Ryan Lerch <[email protected]>
|
Python
|
lgpl-2.1
|
fedora-infra/fmn,fedora-infra/fmn,fedora-infra/fmn,fedora-infra/fmn,fedora-infra/fmn
|
import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True, scope="session")
def configured_cache():
cache.configure()
Fix intermittent failures of test_guard_http_exception
Signed-off-by: Ryan Lerch <[email protected]>
|
import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True)
def configured_cache():
if not cache.region.is_configured:
cache.configure()
yield
cache.region.invalidate()
|
<commit_before>import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True, scope="session")
def configured_cache():
cache.configure()
<commit_msg>Fix intermittent failures of test_guard_http_exception
Signed-off-by: Ryan Lerch <[email protected]><commit_after>
|
import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True)
def configured_cache():
if not cache.region.is_configured:
cache.configure()
yield
cache.region.invalidate()
|
import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True, scope="session")
def configured_cache():
cache.configure()
Fix intermittent failures of test_guard_http_exception
Signed-off-by: Ryan Lerch <[email protected]>import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True)
def configured_cache():
if not cache.region.is_configured:
cache.configure()
yield
cache.region.invalidate()
|
<commit_before>import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True, scope="session")
def configured_cache():
cache.configure()
<commit_msg>Fix intermittent failures of test_guard_http_exception
Signed-off-by: Ryan Lerch <[email protected]><commit_after>import pytest
from fmn.rules.cache import cache
@pytest.fixture(autouse=True)
def configured_cache():
if not cache.region.is_configured:
cache.configure()
yield
cache.region.invalidate()
|
f5463ae38c4cd46af043f30d0e7d28cf5d1727db
|
flow/commands/update_software_command.py
|
flow/commands/update_software_command.py
|
import subprocess
from command import Command
from . import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response().success is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
|
import subprocess
from command import Command
from list_versions_command import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response()['success'] is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
|
Fix version list validation check.
|
Fix version list validation check.
[#152092418]
|
Python
|
mit
|
manylabs/flow,manylabs/flow
|
import subprocess
from command import Command
from . import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response().success is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
Fix version list validation check.
[#152092418]
|
import subprocess
from command import Command
from list_versions_command import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response()['success'] is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
|
<commit_before>import subprocess
from command import Command
from . import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response().success is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
<commit_msg>Fix version list validation check.
[#152092418]<commit_after>
|
import subprocess
from command import Command
from list_versions_command import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response()['success'] is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
|
import subprocess
from command import Command
from . import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response().success is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
Fix version list validation check.
[#152092418]import subprocess
from command import Command
from list_versions_command import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response()['success'] is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
|
<commit_before>import subprocess
from command import Command
from . import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response().success is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
<commit_msg>Fix version list validation check.
[#152092418]<commit_after>import subprocess
from command import Command
from list_versions_command import ListVersionsCommand
from ..git_tools import git_base_command
class UpdateSoftwareCommand(Command):
def __init__(self, flow, cmd_name, params):
Command.__init__(self, flow, cmd_name, params)
def exec_impl(self):
release = self.params['release']
list_cmd = ListVersionsCommand(None, None, {})
list_cmd.exec_cmd()
if list_cmd.get_response()['success'] is False:
self.response = {
'success': False,
'message': 'Unable to list available versions.' }
return
if not release in list_cmd.get_response()['version_list']:
self.response = {
'success': False,
'message': 'Version %s is not available' % (release) }
return
self.shell_helper(git_base_command() + ['checkout', 'tags/'+release])
if self.flow is not None:
self.flow.set_operational_status(self.flow.OP_STATUS_UPDATING)
self.response = {
'success': True,
'message': 'Software version updating to %s' % (tag) }
def post_exec(self):
if self.flow is not None:
self.flow.send_status()
self.shell_helper(['sudo', 'reboot'])
|
2fc23ca753ca68d3c0531cf9c58d5864adfc373f
|
tests/test_short_url.py
|
tests/test_short_url.py
|
# -*- coding: utf-8 -*-
import unittest
from random import randrange
import short_url
class TestShortUrl(unittest.TestCase):
def test_one(self):
url = short_url.encode_url(12)
self.assertEqual(url, 'jy7yj')
key = short_url.decode_url(url)
self.assertEqual(key, 12)
def test_1000_random(self):
for random_int in range(1000):
random_int = randrange(100000000)
url = short_url.encode_url(random_int)
int_ = short_url.decode_url(url)
self.assertEqual(random_int, int_)
def test_custom_alphabet(self):
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
self.assertEqual(url, 'bbaaaaaaaaaaaaaaaaaaaa')
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
self.assertEqual(key, 12)
def test_short_alphabet(self):
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='a')
|
# -*- coding: utf-8 -*-
from random import randrange
from pytest import raises
import short_url
def test_custom_alphabet():
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
assert url == 'bbaaaaaaaaaaaaaaaaaaaa'
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
assert key == 12
def test_too_short_alphabet():
with raises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with raises(AttributeError):
short_url.UrlEncoder(alphabet='a')
|
Use simple test functions and remove too special tests
|
Use simple test functions and remove too special tests
|
Python
|
mit
|
Alir3z4/python-short_url
|
# -*- coding: utf-8 -*-
import unittest
from random import randrange
import short_url
class TestShortUrl(unittest.TestCase):
def test_one(self):
url = short_url.encode_url(12)
self.assertEqual(url, 'jy7yj')
key = short_url.decode_url(url)
self.assertEqual(key, 12)
def test_1000_random(self):
for random_int in range(1000):
random_int = randrange(100000000)
url = short_url.encode_url(random_int)
int_ = short_url.decode_url(url)
self.assertEqual(random_int, int_)
def test_custom_alphabet(self):
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
self.assertEqual(url, 'bbaaaaaaaaaaaaaaaaaaaa')
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
self.assertEqual(key, 12)
def test_short_alphabet(self):
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='a')
Use simple test functions and remove too special tests
|
# -*- coding: utf-8 -*-
from random import randrange
from pytest import raises
import short_url
def test_custom_alphabet():
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
assert url == 'bbaaaaaaaaaaaaaaaaaaaa'
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
assert key == 12
def test_too_short_alphabet():
with raises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with raises(AttributeError):
short_url.UrlEncoder(alphabet='a')
|
<commit_before># -*- coding: utf-8 -*-
import unittest
from random import randrange
import short_url
class TestShortUrl(unittest.TestCase):
def test_one(self):
url = short_url.encode_url(12)
self.assertEqual(url, 'jy7yj')
key = short_url.decode_url(url)
self.assertEqual(key, 12)
def test_1000_random(self):
for random_int in range(1000):
random_int = randrange(100000000)
url = short_url.encode_url(random_int)
int_ = short_url.decode_url(url)
self.assertEqual(random_int, int_)
def test_custom_alphabet(self):
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
self.assertEqual(url, 'bbaaaaaaaaaaaaaaaaaaaa')
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
self.assertEqual(key, 12)
def test_short_alphabet(self):
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='a')
<commit_msg>Use simple test functions and remove too special tests<commit_after>
|
# -*- coding: utf-8 -*-
from random import randrange
from pytest import raises
import short_url
def test_custom_alphabet():
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
assert url == 'bbaaaaaaaaaaaaaaaaaaaa'
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
assert key == 12
def test_too_short_alphabet():
with raises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with raises(AttributeError):
short_url.UrlEncoder(alphabet='a')
|
# -*- coding: utf-8 -*-
import unittest
from random import randrange
import short_url
class TestShortUrl(unittest.TestCase):
def test_one(self):
url = short_url.encode_url(12)
self.assertEqual(url, 'jy7yj')
key = short_url.decode_url(url)
self.assertEqual(key, 12)
def test_1000_random(self):
for random_int in range(1000):
random_int = randrange(100000000)
url = short_url.encode_url(random_int)
int_ = short_url.decode_url(url)
self.assertEqual(random_int, int_)
def test_custom_alphabet(self):
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
self.assertEqual(url, 'bbaaaaaaaaaaaaaaaaaaaa')
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
self.assertEqual(key, 12)
def test_short_alphabet(self):
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='a')
Use simple test functions and remove too special tests# -*- coding: utf-8 -*-
from random import randrange
from pytest import raises
import short_url
def test_custom_alphabet():
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
assert url == 'bbaaaaaaaaaaaaaaaaaaaa'
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
assert key == 12
def test_too_short_alphabet():
with raises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with raises(AttributeError):
short_url.UrlEncoder(alphabet='a')
|
<commit_before># -*- coding: utf-8 -*-
import unittest
from random import randrange
import short_url
class TestShortUrl(unittest.TestCase):
def test_one(self):
url = short_url.encode_url(12)
self.assertEqual(url, 'jy7yj')
key = short_url.decode_url(url)
self.assertEqual(key, 12)
def test_1000_random(self):
for random_int in range(1000):
random_int = randrange(100000000)
url = short_url.encode_url(random_int)
int_ = short_url.decode_url(url)
self.assertEqual(random_int, int_)
def test_custom_alphabet(self):
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
self.assertEqual(url, 'bbaaaaaaaaaaaaaaaaaaaa')
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
self.assertEqual(key, 12)
def test_short_alphabet(self):
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with self.assertRaises(AttributeError):
short_url.UrlEncoder(alphabet='a')
<commit_msg>Use simple test functions and remove too special tests<commit_after># -*- coding: utf-8 -*-
from random import randrange
from pytest import raises
import short_url
def test_custom_alphabet():
encoder = short_url.UrlEncoder(alphabet='ab')
url = encoder.encode_url(12)
assert url == 'bbaaaaaaaaaaaaaaaaaaaa'
key = encoder.decode_url('bbaaaaaaaaaaaaaaaaaaaa')
assert key == 12
def test_too_short_alphabet():
with raises(AttributeError):
short_url.UrlEncoder(alphabet='aa')
with raises(AttributeError):
short_url.UrlEncoder(alphabet='a')
|
8653159dcf6a078bc2193293b93457388e7799d3
|
tests/tests.py
|
tests/tests.py
|
import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
|
import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def output_is_not_truncated_when_not_ending_in_a_newline(shell):
result = shell.run(["echo", "-n", "hello"])
assert_equal("hello", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
|
Add test for output that doesn't end in a newline
|
Add test for output that doesn't end in a newline
|
Python
|
bsd-2-clause
|
mwilliamson/spur.py
|
import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
Add test for output that doesn't end in a newline
|
import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def output_is_not_truncated_when_not_ending_in_a_newline(shell):
result = shell.run(["echo", "-n", "hello"])
assert_equal("hello", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
|
<commit_before>import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
<commit_msg>Add test for output that doesn't end in a newline<commit_after>
|
import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def output_is_not_truncated_when_not_ending_in_a_newline(shell):
result = shell.run(["echo", "-n", "hello"])
assert_equal("hello", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
|
import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
Add test for output that doesn't end in a newlineimport functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def output_is_not_truncated_when_not_ending_in_a_newline(shell):
result = shell.run(["echo", "-n", "hello"])
assert_equal("hello", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
|
<commit_before>import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
<commit_msg>Add test for output that doesn't end in a newline<commit_after>import functools
import os
from nose.tools import istest, assert_equal
import spur
def test(func):
@functools.wraps(func)
def run_test():
for shell in _create_shells():
yield func, shell
def _create_shells():
return [
spur.LocalShell(),
_create_ssh_shell()
]
def _create_ssh_shell():
return spur.SshShell(
hostname=os.environ.get("TEST_SSH_HOSTNAME", "127.0.0.1"),
username=os.environ["TEST_SSH_USERNAME"],
password=os.environ["TEST_SSH_PASSWORD"],
port=int(os.environ.get("TEST_SSH_PORT"))
)
return istest(run_test)
@test
def output_of_run_is_stored(shell):
result = shell.run(["echo", "hello"])
assert_equal("hello\n", result.output)
@test
def output_is_not_truncated_when_not_ending_in_a_newline(shell):
result = shell.run(["echo", "-n", "hello"])
assert_equal("hello", result.output)
@test
def cwd_of_run_can_be_set(shell):
result = shell.run(["pwd"], cwd="/")
assert_equal("/\n", result.output)
@test
def environment_variables_can_be_added_for_run(shell):
result = shell.run(["sh", "-c", "echo $NAME"], update_env={"NAME": "Bob"})
assert_equal("Bob\n", result.output)
|
f4e07b93ab81fd0a0dc59ec77fca596a2fcca738
|
froide/helper/form_utils.py
|
froide/helper/form_utils.py
|
import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: e.get_json_data() for f, e in self.errors.items()},
'nonFieldErrors': [e.get_json_data() for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
|
import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
def get_data(error):
if isinstance(error, (dict, str)):
return error
return error.get_json_data()
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: get_data(e) for f, e in self.errors.items()},
'nonFieldErrors': [get_data(e) for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
|
Fix serialization of form errors
|
Fix serialization of form errors
|
Python
|
mit
|
fin/froide,fin/froide,fin/froide,stefanw/froide,stefanw/froide,stefanw/froide,stefanw/froide,stefanw/froide,fin/froide
|
import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: e.get_json_data() for f, e in self.errors.items()},
'nonFieldErrors': [e.get_json_data() for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
Fix serialization of form errors
|
import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
def get_data(error):
if isinstance(error, (dict, str)):
return error
return error.get_json_data()
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: get_data(e) for f, e in self.errors.items()},
'nonFieldErrors': [get_data(e) for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
|
<commit_before>import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: e.get_json_data() for f, e in self.errors.items()},
'nonFieldErrors': [e.get_json_data() for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
<commit_msg>Fix serialization of form errors<commit_after>
|
import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
def get_data(error):
if isinstance(error, (dict, str)):
return error
return error.get_json_data()
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: get_data(e) for f, e in self.errors.items()},
'nonFieldErrors': [get_data(e) for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
|
import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: e.get_json_data() for f, e in self.errors.items()},
'nonFieldErrors': [e.get_json_data() for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
Fix serialization of form errorsimport json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
def get_data(error):
if isinstance(error, (dict, str)):
return error
return error.get_json_data()
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: get_data(e) for f, e in self.errors.items()},
'nonFieldErrors': [get_data(e) for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
|
<commit_before>import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: e.get_json_data() for f, e in self.errors.items()},
'nonFieldErrors': [e.get_json_data() for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
<commit_msg>Fix serialization of form errors<commit_after>import json
from django.db import models
class DjangoJSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, models.Model) and hasattr(obj, 'as_data'):
return obj.as_data()
return json.JSONEncoder.default(self, obj)
def get_data(error):
if isinstance(error, (dict, str)):
return error
return error.get_json_data()
class JSONMixin(object):
def as_json(self):
return json.dumps(self.as_data(), cls=DjangoJSONEncoder)
def as_data(self):
return {
'fields': {
str(name): self.field_to_dict(name, field) for name, field in self.fields.items()
},
'errors': {f: get_data(e) for f, e in self.errors.items()},
'nonFieldErrors': [get_data(e) for e in self.non_field_errors()]
}
def field_to_dict(self, name, field):
return {
"type": field.__class__.__name__,
"widget_type": field.widget.__class__.__name__,
"hidden": field.widget.is_hidden,
"required": field.widget.is_required,
"label": str(field.label),
"help_text": str(field.help_text),
"initial": self.get_initial_for_field(field, name),
"placeholder": str(field.widget.attrs.get('placeholder', '')),
"value": self[name].value() if self.is_bound else None
}
|
e8092ec82ff8ee9c0104b507751e45555c08685b
|
tests/tests.py
|
tests/tests.py
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].name, "tortilla chips")
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].name, " salsa")
self.assertEqual(tags[0].slug, "salsa")
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].slug, "salsa")
|
Fix test on python 3.3
|
Fix test on python 3.3
|
Python
|
mit
|
avelino/django-tags
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].name, "tortilla chips")
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].name, " salsa")
self.assertEqual(tags[0].slug, "salsa")
Fix test on python 3.3
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].slug, "salsa")
|
<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].name, "tortilla chips")
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].name, " salsa")
self.assertEqual(tags[0].slug, "salsa")
<commit_msg>Fix test on python 3.3<commit_after>
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].slug, "salsa")
|
# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].name, "tortilla chips")
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].name, " salsa")
self.assertEqual(tags[0].slug, "salsa")
Fix test on python 3.3# -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].slug, "salsa")
|
<commit_before># -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].name, "tortilla chips")
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].name, " salsa")
self.assertEqual(tags[0].slug, "salsa")
<commit_msg>Fix test on python 3.3<commit_after># -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
from django.test import TestCase
from tags.models import Tag
from .models import Food
class TestFoodModel(TestCase):
def test_create_food(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips")
self.assertTrue(food)
self.assertEqual(Tag.objects.all()[0].name, "tortilla chips")
self.assertEqual(Tag.objects.all()[0].slug, "tortilla-chips")
def test_create_two_tags(self):
food = Food.objects.create(
name="nacho",
tags="tortilla chips, salsa")
tags = Tag.objects.all()
self.assertTrue(food)
self.assertEqual(len(tags), 2)
self.assertEqual(tags[1].slug, "tortilla-chips")
self.assertEqual(tags[0].slug, "salsa")
|
6e9095efe0251d951eea553ccb578e3ed5909b7f
|
tests/utils.py
|
tests/utils.py
|
import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.iteritems():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.iteritems():
setattr(settings, name, value)
|
import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.items():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.items():
setattr(settings, name, value)
|
Update pipeline_settings to support Python 3
|
Update pipeline_settings to support Python 3
|
Python
|
mit
|
cyberdelia/django-pipeline,ei-grad/django-pipeline,caioariede/django-pipeline,beedesk/django-pipeline,camilonova/django-pipeline,ei-grad/django-pipeline,chipx86/django-pipeline,simudream/django-pipeline,Tekco/django-pipeline,Tekco/django-pipeline,d9pouces/django-pipeline,wienczny/django-pipeline,Kobold/django-pipeline,tayfun/django-pipeline,botify-labs/django-pipeline,jazzband/django-pipeline,mgorny/django-pipeline,Kobold/django-pipeline,kronion/django-pipeline,TwigWorld/django-pipeline,adamcharnock/django-pipeline,almost/django-pipeline,zapier/django-pipeline,novapost/django-pipeline,almost/django-pipeline,TwigWorld/django-pipeline,sideffect0/django-pipeline,sideffect0/django-pipeline,leonardoo/django-pipeline,Kami/django-pipeline,demux/django-pipeline,lexqt/django-pipeline,joshkehn/django-pipeline,beedesk/django-pipeline,lexqt/django-pipeline,chipx86/django-pipeline,botify-labs/django-pipeline,adamcharnock/django-pipeline,sideffect0/django-pipeline,skolsuper/django-pipeline,leonardoo/django-pipeline,zapier/django-pipeline,skirsdeda/django-pipeline,jazzband/django-pipeline,joshkehn/django-pipeline,adamcharnock/django-pipeline,Kami/django-pipeline,tayfun/django-pipeline,edwinlunando/django-pipeline,cyberdelia/django-pipeline,perdona/django-pipeline,tayfun/django-pipeline,perdona/django-pipeline,cyberdelia/django-pipeline,kronion/django-pipeline,lydell/django-pipeline,jazzband/django-pipeline,edwinlunando/django-pipeline,lexqt/django-pipeline,chipx86/django-pipeline,novapost/django-pipeline,wienczny/django-pipeline,ei-grad/django-pipeline,jwatson/django-pipeline,TwigWorld/django-pipeline,demux/django-pipeline,lydell/django-pipeline,jwatson/django-pipeline,leonardoo/django-pipeline,beedesk/django-pipeline,theatlantic/django-pipeline,floppym/django-pipeline,novapost/django-pipeline,yuvadm/django-pipeline,theatlantic/django-pipeline,skirsdeda/django-pipeline,mgorny/django-pipeline,kronion/django-pipeline,d9pouces/django-pipeline,wienczny/django-pipeline,floppym/django-pipeline,Kami/django-pipeline,zapier/django-pipeline,edwinlunando/django-pipeline,joshkehn/django-pipeline,theatlantic/django-pipeline,jwatson/django-pipeline,demux/django-pipeline,botify-labs/django-pipeline,perdona/django-pipeline,skirsdeda/django-pipeline,camilonova/django-pipeline,skolsuper/django-pipeline,Kobold/django-pipeline,Tekco/django-pipeline,yuvadm/django-pipeline,apendleton/django-pipeline,lydell/django-pipeline,apendleton/django-pipeline,yuvadm/django-pipeline,simudream/django-pipeline,almost/django-pipeline,camilonova/django-pipeline,apendleton/django-pipeline,mgorny/django-pipeline,caioariede/django-pipeline,d9pouces/django-pipeline,simudream/django-pipeline,skolsuper/django-pipeline,caioariede/django-pipeline,floppym/django-pipeline
|
import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.iteritems():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.iteritems():
setattr(settings, name, value)
Update pipeline_settings to support Python 3
|
import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.items():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.items():
setattr(settings, name, value)
|
<commit_before>import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.iteritems():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.iteritems():
setattr(settings, name, value)
<commit_msg>Update pipeline_settings to support Python 3<commit_after>
|
import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.items():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.items():
setattr(settings, name, value)
|
import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.iteritems():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.iteritems():
setattr(settings, name, value)
Update pipeline_settings to support Python 3import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.items():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.items():
setattr(settings, name, value)
|
<commit_before>import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.iteritems():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.iteritems():
setattr(settings, name, value)
<commit_msg>Update pipeline_settings to support Python 3<commit_after>import contextlib
import os
from pipeline.conf import settings
def _(path):
# Make sure the path contains only the correct separator
return path.replace('/', os.sep).replace('\\', os.sep)
@contextlib.contextmanager
def pipeline_settings(**kwargs):
try:
saved = {}
for name, value in kwargs.items():
saved[name] = getattr(settings, name)
setattr(settings, name, value)
yield
finally:
for name, value in saved.items():
setattr(settings, name, value)
|
eae8053398c26ede98c4e253caf7f29f930b2f97
|
compile.py
|
compile.py
|
from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES = [
'gunicorn/workers/_gaiohttp.py',
'pymysql/_socketio.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
for e in EXCLUDES:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
|
from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES_27 = [
'pymysql/_socketio.py',
]
EXCLUDES_34 = [
'gunicorn/workers/_gaiohttp.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
excludes = []
if sys.version_info < (2, 7):
excludes.extend(EXCLUDES_27)
if sys.version_info < (3, 4):
excludes.extend(EXCLUDES_34)
for e in excludes:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
|
Split the Python specific version exludes between 2.7/3.4 specific syntax.
|
Split the Python specific version exludes between 2.7/3.4 specific syntax.
|
Python
|
apache-2.0
|
therewillbecode/ichnaea,mozilla/ichnaea,therewillbecode/ichnaea,mozilla/ichnaea,mozilla/ichnaea,mozilla/ichnaea,therewillbecode/ichnaea
|
from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES = [
'gunicorn/workers/_gaiohttp.py',
'pymysql/_socketio.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
for e in EXCLUDES:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
Split the Python specific version exludes between 2.7/3.4 specific syntax.
|
from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES_27 = [
'pymysql/_socketio.py',
]
EXCLUDES_34 = [
'gunicorn/workers/_gaiohttp.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
excludes = []
if sys.version_info < (2, 7):
excludes.extend(EXCLUDES_27)
if sys.version_info < (3, 4):
excludes.extend(EXCLUDES_34)
for e in excludes:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
|
<commit_before>from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES = [
'gunicorn/workers/_gaiohttp.py',
'pymysql/_socketio.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
for e in EXCLUDES:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
<commit_msg>Split the Python specific version exludes between 2.7/3.4 specific syntax.<commit_after>
|
from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES_27 = [
'pymysql/_socketio.py',
]
EXCLUDES_34 = [
'gunicorn/workers/_gaiohttp.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
excludes = []
if sys.version_info < (2, 7):
excludes.extend(EXCLUDES_27)
if sys.version_info < (3, 4):
excludes.extend(EXCLUDES_34)
for e in excludes:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
|
from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES = [
'gunicorn/workers/_gaiohttp.py',
'pymysql/_socketio.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
for e in EXCLUDES:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
Split the Python specific version exludes between 2.7/3.4 specific syntax.from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES_27 = [
'pymysql/_socketio.py',
]
EXCLUDES_34 = [
'gunicorn/workers/_gaiohttp.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
excludes = []
if sys.version_info < (2, 7):
excludes.extend(EXCLUDES_27)
if sys.version_info < (3, 4):
excludes.extend(EXCLUDES_34)
for e in excludes:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
|
<commit_before>from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES = [
'gunicorn/workers/_gaiohttp.py',
'pymysql/_socketio.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
for e in EXCLUDES:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
<commit_msg>Split the Python specific version exludes between 2.7/3.4 specific syntax.<commit_after>from compileall import compile_dir
from distutils.sysconfig import get_python_lib
import os
import os.path
import sys
EXCLUDES_27 = [
'pymysql/_socketio.py',
]
EXCLUDES_34 = [
'gunicorn/workers/_gaiohttp.py',
]
def compile_files(path):
return compile_dir(path, maxlevels=50, quiet=True)
def remove_python3_files(path):
excludes = []
if sys.version_info < (2, 7):
excludes.extend(EXCLUDES_27)
if sys.version_info < (3, 4):
excludes.extend(EXCLUDES_34)
for e in excludes:
fp = os.path.join(path, e)
for extension in ('', 'c', 'o'):
name = fp + extension
if os.path.exists(name):
print('Removing file %s containing Python 3 syntax.' % name)
os.remove(name)
def main():
sp = get_python_lib()
remove_python3_files(sp)
status = compile_files(sp)
sys.exit(not status)
if __name__ == '__main__':
main()
|
bf0407914cfa85312d3fde79e83f86d00c2d2235
|
upgrade_dbs.py
|
upgrade_dbs.py
|
#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
from defines import *
import pdb
if __name__ == "__main__":
gm = gm_m.GamesMgr()
#pdb.set_trace()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
for g_id in to_remove:
gm.remove_id(g_id)
|
#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
import players_mgr as pm_m
from defines import *
import sys
import os
def dot():
sys.stdout.write('.')
sys.stdout.flush()
if __name__ == "__main__":
print "Upgrading Players"
pm = pm_m.PlayersMgr()
for p_id, genome in pm.players.iteritems():
if p_id == "max_id":
continue
sys.stdout.write('.')
dot()
pm.save(genome)
print "Upgrading Games"
gm = gm_m.GamesMgr()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
dot()
for g_id in to_remove:
dot()
gm.remove_id(g_id)
# TODO upgrade openings
|
Upgrade players DB; show progress
|
Upgrade players DB; show progress
|
Python
|
mit
|
cropleyb/pentai,cropleyb/pentai,cropleyb/pentai
|
#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
from defines import *
import pdb
if __name__ == "__main__":
gm = gm_m.GamesMgr()
#pdb.set_trace()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
for g_id in to_remove:
gm.remove_id(g_id)
Upgrade players DB; show progress
|
#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
import players_mgr as pm_m
from defines import *
import sys
import os
def dot():
sys.stdout.write('.')
sys.stdout.flush()
if __name__ == "__main__":
print "Upgrading Players"
pm = pm_m.PlayersMgr()
for p_id, genome in pm.players.iteritems():
if p_id == "max_id":
continue
sys.stdout.write('.')
dot()
pm.save(genome)
print "Upgrading Games"
gm = gm_m.GamesMgr()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
dot()
for g_id in to_remove:
dot()
gm.remove_id(g_id)
# TODO upgrade openings
|
<commit_before>#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
from defines import *
import pdb
if __name__ == "__main__":
gm = gm_m.GamesMgr()
#pdb.set_trace()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
for g_id in to_remove:
gm.remove_id(g_id)
<commit_msg>Upgrade players DB; show progress<commit_after>
|
#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
import players_mgr as pm_m
from defines import *
import sys
import os
def dot():
sys.stdout.write('.')
sys.stdout.flush()
if __name__ == "__main__":
print "Upgrading Players"
pm = pm_m.PlayersMgr()
for p_id, genome in pm.players.iteritems():
if p_id == "max_id":
continue
sys.stdout.write('.')
dot()
pm.save(genome)
print "Upgrading Games"
gm = gm_m.GamesMgr()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
dot()
for g_id in to_remove:
dot()
gm.remove_id(g_id)
# TODO upgrade openings
|
#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
from defines import *
import pdb
if __name__ == "__main__":
gm = gm_m.GamesMgr()
#pdb.set_trace()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
for g_id in to_remove:
gm.remove_id(g_id)
Upgrade players DB; show progress#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
import players_mgr as pm_m
from defines import *
import sys
import os
def dot():
sys.stdout.write('.')
sys.stdout.flush()
if __name__ == "__main__":
print "Upgrading Players"
pm = pm_m.PlayersMgr()
for p_id, genome in pm.players.iteritems():
if p_id == "max_id":
continue
sys.stdout.write('.')
dot()
pm.save(genome)
print "Upgrading Games"
gm = gm_m.GamesMgr()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
dot()
for g_id in to_remove:
dot()
gm.remove_id(g_id)
# TODO upgrade openings
|
<commit_before>#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
from defines import *
import pdb
if __name__ == "__main__":
gm = gm_m.GamesMgr()
#pdb.set_trace()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
for g_id in to_remove:
gm.remove_id(g_id)
<commit_msg>Upgrade players DB; show progress<commit_after>#!/usr/bin/python
import games_mgr as gm_m
import openings_book as ol_m
import player as p_m
import players_mgr as pm_m
from defines import *
import sys
import os
def dot():
sys.stdout.write('.')
sys.stdout.flush()
if __name__ == "__main__":
print "Upgrading Players"
pm = pm_m.PlayersMgr()
for p_id, genome in pm.players.iteritems():
if p_id == "max_id":
continue
sys.stdout.write('.')
dot()
pm.save(genome)
print "Upgrading Games"
gm = gm_m.GamesMgr()
to_remove = []
unknown = p_m.Player("Unknown")
for g_id in gm.id_lookup.iterkeys():
if g_id == "id":
continue
try:
game = gm.get_game(g_id)
except KeyError:
print "Removing game %s" % g_id
to_remove.append(g_id)
continue
for colour in (BLACK,WHITE):
if game.players[colour] is None:
game.players[colour] = unknown
gm.save(game)
dot()
for g_id in to_remove:
dot()
gm.remove_id(g_id)
# TODO upgrade openings
|
ca74738e9241230fd0cc843aa9b76f67494d02eb
|
python/intermediate/create_inter_python_data.py
|
python/intermediate/create_inter_python_data.py
|
"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
years = np.arange(1960, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = 0.5 * temps + 0.7 * rainfalls + noise
data = zip(years, temps, rainfalls, mosquitos)
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv('mosquito_data_A2.csv', index=False, float_format='%.0f')
df_short = df[-10:]
df_short.to_csv('mosquito_data_A1.csv', index=False, float_format='%.0f')
|
"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
datasets = {'A1': [0, 0.5, 0.7, 10],
'A2': [0, 0.5, 0.7, 50],
'A3': [0, 0.5, 0.3, 50],
'B1': [3, 0.7, 0.2, 50],
'B2': [3, 0.7, 0.7, 50]}
def make_data(intercept, tempslope, rainfallslope, numyears):
years = np.arange(2010 - numyears, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = intercept + tempslope * temps + rainfallslope * rainfalls + noise
return zip(years, temps, rainfalls, mosquitos)
def export_data(data, filename):
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv(filename, index=False, float_format='%.0f')
for site in datasets:
data = make_data(*datasets[site])
if site == 'A1':
#create a shorter dataset for first example
data = data[-10:]
export_data(data, '%s_mosquito_data.csv' % site)
|
Allow creation of multiple example data files for Inter Python
|
Allow creation of multiple example data files for Inter Python
Generalizes the script for creating data files to allow for the
easy generation of larger numbers of data files.
|
Python
|
bsd-2-clause
|
selimnairb/2014-02-25-swctest,selimnairb/2014-02-25-swctest,selimnairb/2014-02-25-swctest,selimnairb/2014-02-25-swctest,selimnairb/2014-02-25-swctest,selimnairb/2014-02-25-swctest
|
"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
years = np.arange(1960, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = 0.5 * temps + 0.7 * rainfalls + noise
data = zip(years, temps, rainfalls, mosquitos)
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv('mosquito_data_A2.csv', index=False, float_format='%.0f')
df_short = df[-10:]
df_short.to_csv('mosquito_data_A1.csv', index=False, float_format='%.0f')
Allow creation of multiple example data files for Inter Python
Generalizes the script for creating data files to allow for the
easy generation of larger numbers of data files.
|
"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
datasets = {'A1': [0, 0.5, 0.7, 10],
'A2': [0, 0.5, 0.7, 50],
'A3': [0, 0.5, 0.3, 50],
'B1': [3, 0.7, 0.2, 50],
'B2': [3, 0.7, 0.7, 50]}
def make_data(intercept, tempslope, rainfallslope, numyears):
years = np.arange(2010 - numyears, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = intercept + tempslope * temps + rainfallslope * rainfalls + noise
return zip(years, temps, rainfalls, mosquitos)
def export_data(data, filename):
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv(filename, index=False, float_format='%.0f')
for site in datasets:
data = make_data(*datasets[site])
if site == 'A1':
#create a shorter dataset for first example
data = data[-10:]
export_data(data, '%s_mosquito_data.csv' % site)
|
<commit_before>"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
years = np.arange(1960, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = 0.5 * temps + 0.7 * rainfalls + noise
data = zip(years, temps, rainfalls, mosquitos)
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv('mosquito_data_A2.csv', index=False, float_format='%.0f')
df_short = df[-10:]
df_short.to_csv('mosquito_data_A1.csv', index=False, float_format='%.0f')
<commit_msg>Allow creation of multiple example data files for Inter Python
Generalizes the script for creating data files to allow for the
easy generation of larger numbers of data files.<commit_after>
|
"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
datasets = {'A1': [0, 0.5, 0.7, 10],
'A2': [0, 0.5, 0.7, 50],
'A3': [0, 0.5, 0.3, 50],
'B1': [3, 0.7, 0.2, 50],
'B2': [3, 0.7, 0.7, 50]}
def make_data(intercept, tempslope, rainfallslope, numyears):
years = np.arange(2010 - numyears, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = intercept + tempslope * temps + rainfallslope * rainfalls + noise
return zip(years, temps, rainfalls, mosquitos)
def export_data(data, filename):
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv(filename, index=False, float_format='%.0f')
for site in datasets:
data = make_data(*datasets[site])
if site == 'A1':
#create a shorter dataset for first example
data = data[-10:]
export_data(data, '%s_mosquito_data.csv' % site)
|
"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
years = np.arange(1960, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = 0.5 * temps + 0.7 * rainfalls + noise
data = zip(years, temps, rainfalls, mosquitos)
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv('mosquito_data_A2.csv', index=False, float_format='%.0f')
df_short = df[-10:]
df_short.to_csv('mosquito_data_A1.csv', index=False, float_format='%.0f')
Allow creation of multiple example data files for Inter Python
Generalizes the script for creating data files to allow for the
easy generation of larger numbers of data files."""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
datasets = {'A1': [0, 0.5, 0.7, 10],
'A2': [0, 0.5, 0.7, 50],
'A3': [0, 0.5, 0.3, 50],
'B1': [3, 0.7, 0.2, 50],
'B2': [3, 0.7, 0.7, 50]}
def make_data(intercept, tempslope, rainfallslope, numyears):
years = np.arange(2010 - numyears, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = intercept + tempslope * temps + rainfallslope * rainfalls + noise
return zip(years, temps, rainfalls, mosquitos)
def export_data(data, filename):
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv(filename, index=False, float_format='%.0f')
for site in datasets:
data = make_data(*datasets[site])
if site == 'A1':
#create a shorter dataset for first example
data = data[-10:]
export_data(data, '%s_mosquito_data.csv' % site)
|
<commit_before>"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
years = np.arange(1960, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = 0.5 * temps + 0.7 * rainfalls + noise
data = zip(years, temps, rainfalls, mosquitos)
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv('mosquito_data_A2.csv', index=False, float_format='%.0f')
df_short = df[-10:]
df_short.to_csv('mosquito_data_A1.csv', index=False, float_format='%.0f')
<commit_msg>Allow creation of multiple example data files for Inter Python
Generalizes the script for creating data files to allow for the
easy generation of larger numbers of data files.<commit_after>"""Create the data for the Software Carpentry Intermediate Python lectures"""
import numpy as np
import pandas as pd
np.random.seed(26)
datasets = {'A1': [0, 0.5, 0.7, 10],
'A2': [0, 0.5, 0.7, 50],
'A3': [0, 0.5, 0.3, 50],
'B1': [3, 0.7, 0.2, 50],
'B2': [3, 0.7, 0.7, 50]}
def make_data(intercept, tempslope, rainfallslope, numyears):
years = np.arange(2010 - numyears, 2011)
temps = np.random.uniform(70, 90, len(years))
rainfalls = np.random.uniform(100, 300, len(years))
noise = 2 * np.random.randn(len(years))
mosquitos = intercept + tempslope * temps + rainfallslope * rainfalls + noise
return zip(years, temps, rainfalls, mosquitos)
def export_data(data, filename):
df = pd.DataFrame(data, columns=['year', 'temperature', 'rainfall','mosquitos'])
df.to_csv(filename, index=False, float_format='%.0f')
for site in datasets:
data = make_data(*datasets[site])
if site == 'A1':
#create a shorter dataset for first example
data = data[-10:]
export_data(data, '%s_mosquito_data.csv' % site)
|
9fb12df863e23d8b879f5d92d0f692ac2dcdd91c
|
test_stack.py
|
test_stack.py
|
import pytest
from stack import Element
from stack import Stack
def test_element_init():
n = Element()
assert n.val is None
assert n.next is None
n = Element(3)
assert n.val == 3
assert n.next is None
def test_stack_init():
l = Stack()
assert l.top is None
def test_stack_push():
l = Stack()
e = Element(10)
l.push(e)
assert l.top == e
assert l.top.previous is None
f = Element("String")
l.push(f)
assert l.top == f
assert l.top.previous == e
assert l.top.previous.previous is None
# def test_stack_pop():
# l = stack()
# a = l.pop()
# assert a is None
|
Add tests for init and push
|
Add tests for init and push
|
Python
|
mit
|
constanthatz/data-structures
|
Add tests for init and push
|
import pytest
from stack import Element
from stack import Stack
def test_element_init():
n = Element()
assert n.val is None
assert n.next is None
n = Element(3)
assert n.val == 3
assert n.next is None
def test_stack_init():
l = Stack()
assert l.top is None
def test_stack_push():
l = Stack()
e = Element(10)
l.push(e)
assert l.top == e
assert l.top.previous is None
f = Element("String")
l.push(f)
assert l.top == f
assert l.top.previous == e
assert l.top.previous.previous is None
# def test_stack_pop():
# l = stack()
# a = l.pop()
# assert a is None
|
<commit_before><commit_msg>Add tests for init and push<commit_after>
|
import pytest
from stack import Element
from stack import Stack
def test_element_init():
n = Element()
assert n.val is None
assert n.next is None
n = Element(3)
assert n.val == 3
assert n.next is None
def test_stack_init():
l = Stack()
assert l.top is None
def test_stack_push():
l = Stack()
e = Element(10)
l.push(e)
assert l.top == e
assert l.top.previous is None
f = Element("String")
l.push(f)
assert l.top == f
assert l.top.previous == e
assert l.top.previous.previous is None
# def test_stack_pop():
# l = stack()
# a = l.pop()
# assert a is None
|
Add tests for init and pushimport pytest
from stack import Element
from stack import Stack
def test_element_init():
n = Element()
assert n.val is None
assert n.next is None
n = Element(3)
assert n.val == 3
assert n.next is None
def test_stack_init():
l = Stack()
assert l.top is None
def test_stack_push():
l = Stack()
e = Element(10)
l.push(e)
assert l.top == e
assert l.top.previous is None
f = Element("String")
l.push(f)
assert l.top == f
assert l.top.previous == e
assert l.top.previous.previous is None
# def test_stack_pop():
# l = stack()
# a = l.pop()
# assert a is None
|
<commit_before><commit_msg>Add tests for init and push<commit_after>import pytest
from stack import Element
from stack import Stack
def test_element_init():
n = Element()
assert n.val is None
assert n.next is None
n = Element(3)
assert n.val == 3
assert n.next is None
def test_stack_init():
l = Stack()
assert l.top is None
def test_stack_push():
l = Stack()
e = Element(10)
l.push(e)
assert l.top == e
assert l.top.previous is None
f = Element("String")
l.push(f)
assert l.top == f
assert l.top.previous == e
assert l.top.previous.previous is None
# def test_stack_pop():
# l = stack()
# a = l.pop()
# assert a is None
|
|
9b6a22a9cb908d1fbfa5f9b5081f6c96644115b0
|
tests/test_tags.py
|
tests/test_tags.py
|
from unittest import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'class': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertContains(o, '<script src="/static/js/jquery.js"></script>')
|
#from unittest import TestCase
from django.test import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'processor': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertTrue('<script src="/static/js/jquery.js"></script>' in o)
|
Use TestCase from Django Set STATIC_URL
|
Use TestCase from Django
Set STATIC_URL
|
Python
|
bsd-2-clause
|
funkybob/django-amn
|
from unittest import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'class': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertContains(o, '<script src="/static/js/jquery.js"></script>')
Use TestCase from Django
Set STATIC_URL
|
#from unittest import TestCase
from django.test import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'processor': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertTrue('<script src="/static/js/jquery.js"></script>' in o)
|
<commit_before>
from unittest import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'class': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertContains(o, '<script src="/static/js/jquery.js"></script>')
<commit_msg>Use TestCase from Django
Set STATIC_URL<commit_after>
|
#from unittest import TestCase
from django.test import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'processor': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertTrue('<script src="/static/js/jquery.js"></script>' in o)
|
from unittest import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'class': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertContains(o, '<script src="/static/js/jquery.js"></script>')
Use TestCase from Django
Set STATIC_URL
#from unittest import TestCase
from django.test import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'processor': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertTrue('<script src="/static/js/jquery.js"></script>' in o)
|
<commit_before>
from unittest import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'class': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertContains(o, '<script src="/static/js/jquery.js"></script>')
<commit_msg>Use TestCase from Django
Set STATIC_URL<commit_after>
#from unittest import TestCase
from django.test import TestCase
from django.test.utils import setup_test_template_loader, override_settings
from django.template import Context
from django.template.loader import get_template
TEMPLATES = {
'basetag': '''{% load damn %}{% assets %}''',
'test2': '''
<!doctype html>{% load damn %}
<html>
<head>
{% assets %}
</head>
<body>
{% asset 'js/jquery.js' %}
</body>
</html>
''',
}
DAMN_PROCESSORS = {
'js': {
'processor': 'damn.processors.ScriptProcessor',
},
}
class TagTests(TestCase):
def setUp(self):
setup_test_template_loader(TEMPLATES)
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_simple(self):
t = get_template('basetag')
t.render()
@override_settings(
DAMN_PROCESSORS=DAMN_PROCESSORS,
STATIC_URL = '/',
)
def test_one(self):
t = get_template('test2')
o = t.render(Context())
self.assertTrue('<script src="/static/js/jquery.js"></script>' in o)
|
b245bdcf9a494297ef816c56a98d0477dfbd3d89
|
partner_industry_secondary/models/res_partner.py
|
partner_industry_secondary/models/res_partner.py
|
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
if self.industry_id in self.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
|
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
for partner in self:
if partner.industry_id in partner.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
|
Make api constrains multi to avoid error when create a company with 2 contacts
|
partner_industry_Secondary: Make api constrains multi to avoid error when create a company with 2 contacts
|
Python
|
agpl-3.0
|
BT-rmartin/partner-contact,OCA/partner-contact,OCA/partner-contact,BT-rmartin/partner-contact
|
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
if self.industry_id in self.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
partner_industry_Secondary: Make api constrains multi to avoid error when create a company with 2 contacts
|
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
for partner in self:
if partner.industry_id in partner.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
|
<commit_before># Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
if self.industry_id in self.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
<commit_msg>partner_industry_Secondary: Make api constrains multi to avoid error when create a company with 2 contacts<commit_after>
|
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
for partner in self:
if partner.industry_id in partner.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
|
# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
if self.industry_id in self.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
partner_industry_Secondary: Make api constrains multi to avoid error when create a company with 2 contacts# Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
for partner in self:
if partner.industry_id in partner.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
|
<commit_before># Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
if self.industry_id in self.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
<commit_msg>partner_industry_Secondary: Make api constrains multi to avoid error when create a company with 2 contacts<commit_after># Copyright 2015 Antiun Ingenieria S.L. - Javier Iniesta
# Copyright 2016 Tecnativa S.L. - Vicent Cubells
# Copyright 2018 Eficent Business and IT Consulting Services, S.L.
# License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html).
from odoo import api, exceptions, fields, models, _
class ResPartner(models.Model):
_inherit = 'res.partner'
industry_id = fields.Many2one(string='Main Industry')
secondary_industry_ids = fields.Many2many(
comodel_name='res.partner.industry', string="Secondary Industries",
domain="[('id', '!=', industry_id)]")
@api.constrains('industry_id', 'secondary_industry_ids')
def _check_industries(self):
for partner in self:
if partner.industry_id in partner.secondary_industry_ids:
raise exceptions.ValidationError(
_('The main industry must be different '
'from the secondary industries.'))
|
6336e8e13c01b6a81b8586499e7a3e8fc8b532a8
|
launch_control/commands/interface.py
|
launch_control/commands/interface.py
|
"""
Interface for all launch-control-tool commands
"""
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return cls.__doc__
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
|
"""
Interface for all launch-control-tool commands
"""
import inspect
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return inspect.getdoc(cls)
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
|
Use inspect.getdoc() instead of plain __doc__
|
Use inspect.getdoc() instead of plain __doc__
|
Python
|
agpl-3.0
|
Linaro/lava-server,Linaro/lava-server,OSSystems/lava-server,Linaro/lava-server,OSSystems/lava-server,OSSystems/lava-server,Linaro/lava-server
|
"""
Interface for all launch-control-tool commands
"""
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return cls.__doc__
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
Use inspect.getdoc() instead of plain __doc__
|
"""
Interface for all launch-control-tool commands
"""
import inspect
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return inspect.getdoc(cls)
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
|
<commit_before>"""
Interface for all launch-control-tool commands
"""
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return cls.__doc__
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
<commit_msg>Use inspect.getdoc() instead of plain __doc__ <commit_after>
|
"""
Interface for all launch-control-tool commands
"""
import inspect
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return inspect.getdoc(cls)
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
|
"""
Interface for all launch-control-tool commands
"""
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return cls.__doc__
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
Use inspect.getdoc() instead of plain __doc__ """
Interface for all launch-control-tool commands
"""
import inspect
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return inspect.getdoc(cls)
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
|
<commit_before>"""
Interface for all launch-control-tool commands
"""
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return cls.__doc__
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
<commit_msg>Use inspect.getdoc() instead of plain __doc__ <commit_after>"""
Interface for all launch-control-tool commands
"""
import inspect
from launch_control.utils.registry import RegistryBase
class Command(RegistryBase):
"""
Base class for all command line tool sub-commands.
"""
def __init__(self, parser, args):
"""
Prepare instance for executing commands.
This method is called immediately after all arguments are parsed
and results are available. This gives subclasses a chance to
configure themselves.
The default implementation does not do anything.
"""
pass
def invoke(self, args):
"""
Invoke command action.
"""
raise NotImplemented()
@classmethod
def get_name(cls):
"""
Return the name of this command.
The default implementation strips any leading underscores
and replaces all other underscores with dashes.
"""
return cls.__name__.lstrip("_").replace("_", "-")
@classmethod
def get_help(cls):
"""
Return the help message of this command
"""
return inspect.getdoc(cls)
@classmethod
def register_arguments(cls, parser):
"""
Register arguments if required.
Subclasses can override this to add any arguments that will be
exposed to the command line interface.
"""
pass
|
6fa0131dc85a94833310c4f1a24fac348ff90c7d
|
tools/makefiles.py
|
tools/makefiles.py
|
#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
|
#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast -Wno-writable-strings '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
|
Add -Wno-writable-strings to clean up output
|
Add -Wno-writable-strings to clean up output
|
Python
|
mit
|
f0rki/cb-multios,f0rki/cb-multios,f0rki/cb-multios,f0rki/cb-multios,f0rki/cb-multios
|
#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
Add -Wno-writable-strings to clean up output
|
#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast -Wno-writable-strings '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
|
<commit_before>#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
<commit_msg>Add -Wno-writable-strings to clean up output<commit_after>
|
#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast -Wno-writable-strings '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
|
#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
Add -Wno-writable-strings to clean up output#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast -Wno-writable-strings '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
|
<commit_before>#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
<commit_msg>Add -Wno-writable-strings to clean up output<commit_after>#!/usr/bin/env python
from os import listdir
import re
#reads in old makefile from folder
#parses for compiler arguments
#creates cmake lists file with parsed arguments as parent-scope variables
def readAndMake(folder):
inStream = open(folder+"/Makefile", "r")
oldMake = inStream.readlines()
inStream.close()
makeVars = {'CFLAGS': '-fno-builtin -Wno-int-to-pointer-cast -Wno-writable-strings '}
for line in oldMake:
line = re.sub('[\r\n\t]', '', line)
if "=" in line:
var, val = line.split('=', 1)
var = var.strip()
val = val.strip()
if var == "CFLAGS":
makeVars[var] += val.replace('-Werror', '')
else:
makeVars[var] = val
newMake = ""
for var, val in makeVars.iteritems():
newMake += 'set( {} "{}" )\n'.format(var, val)
newMake += 'buildCB(${CFLAGS})'
outStream = open(folder + "/CMakeLists.txt", "w")
outStream.write(newMake)
outStream.close()
#write makeFiles for all folders in path
def doAll(path):
dirs = listdir(path)
for folder in dirs:
folder = path + "/" + folder
#print folder
if "00" in folder:
print folder
readAndMake(folder)
if __name__ == '__main__':
path = "../cqe-challenges"
doAll(path) ##path should be folder containing multiple challenge binaries and nothing else.
|
612e253d0234e1852db61c589418edbb4add4b00
|
gunicorn.conf.py
|
gunicorn.conf.py
|
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
|
forwarded_allow_ips = '*'
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
|
Disable checking of Front-end IPs
|
Disable checking of Front-end IPs
|
Python
|
agpl-3.0
|
City-of-Helsinki/kuulemma,fastmonkeys/kuulemma,City-of-Helsinki/kuulemma,fastmonkeys/kuulemma,City-of-Helsinki/kuulemma,fastmonkeys/kuulemma
|
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
Disable checking of Front-end IPs
|
forwarded_allow_ips = '*'
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
|
<commit_before>preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
<commit_msg>Disable checking of Front-end IPs<commit_after>
|
forwarded_allow_ips = '*'
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
|
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
Disable checking of Front-end IPsforwarded_allow_ips = '*'
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
|
<commit_before>preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
<commit_msg>Disable checking of Front-end IPs<commit_after>forwarded_allow_ips = '*'
preload_app = True
worker_class = "gunicorn.workers.gthread.ThreadWorker"
|
37c1d6ae1345fbab7aea4404933d78d4b939bbc2
|
hoomd/filters.py
|
hoomd/filters.py
|
import hoomd._hoomd as _hoomd
class ParticleFilterID:
def __init__(self, *args, **kwargs):
args_str = ''.join([str(arg) for arg in args])
kwargs_str = ''.join([str(value)for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
|
import hoomd._hoomd as _hoomd
import numpy as np
class ParticleFilter:
def __init__(self, *args, **kwargs):
args_str = ''.join([repr(arg) if not isinstance(arg, np.ndarray)
else repr(list(arg)) for arg in args])
kwargs_str = ''.join([repr(value) if not isinstance(value, np.ndarray)
else repr(list(value))
for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
|
Change hashing for ParticleFilter python class
|
Change hashing for ParticleFilter python class
|
Python
|
bsd-3-clause
|
joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue,joaander/hoomd-blue
|
import hoomd._hoomd as _hoomd
class ParticleFilterID:
def __init__(self, *args, **kwargs):
args_str = ''.join([str(arg) for arg in args])
kwargs_str = ''.join([str(value)for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
Change hashing for ParticleFilter python class
|
import hoomd._hoomd as _hoomd
import numpy as np
class ParticleFilter:
def __init__(self, *args, **kwargs):
args_str = ''.join([repr(arg) if not isinstance(arg, np.ndarray)
else repr(list(arg)) for arg in args])
kwargs_str = ''.join([repr(value) if not isinstance(value, np.ndarray)
else repr(list(value))
for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
|
<commit_before>import hoomd._hoomd as _hoomd
class ParticleFilterID:
def __init__(self, *args, **kwargs):
args_str = ''.join([str(arg) for arg in args])
kwargs_str = ''.join([str(value)for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
<commit_msg>Change hashing for ParticleFilter python class<commit_after>
|
import hoomd._hoomd as _hoomd
import numpy as np
class ParticleFilter:
def __init__(self, *args, **kwargs):
args_str = ''.join([repr(arg) if not isinstance(arg, np.ndarray)
else repr(list(arg)) for arg in args])
kwargs_str = ''.join([repr(value) if not isinstance(value, np.ndarray)
else repr(list(value))
for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
|
import hoomd._hoomd as _hoomd
class ParticleFilterID:
def __init__(self, *args, **kwargs):
args_str = ''.join([str(arg) for arg in args])
kwargs_str = ''.join([str(value)for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
Change hashing for ParticleFilter python classimport hoomd._hoomd as _hoomd
import numpy as np
class ParticleFilter:
def __init__(self, *args, **kwargs):
args_str = ''.join([repr(arg) if not isinstance(arg, np.ndarray)
else repr(list(arg)) for arg in args])
kwargs_str = ''.join([repr(value) if not isinstance(value, np.ndarray)
else repr(list(value))
for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
|
<commit_before>import hoomd._hoomd as _hoomd
class ParticleFilterID:
def __init__(self, *args, **kwargs):
args_str = ''.join([str(arg) for arg in args])
kwargs_str = ''.join([str(value)for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
<commit_msg>Change hashing for ParticleFilter python class<commit_after>import hoomd._hoomd as _hoomd
import numpy as np
class ParticleFilter:
def __init__(self, *args, **kwargs):
args_str = ''.join([repr(arg) if not isinstance(arg, np.ndarray)
else repr(list(arg)) for arg in args])
kwargs_str = ''.join([repr(value) if not isinstance(value, np.ndarray)
else repr(list(value))
for value in kwargs.values()])
self.args_str = args_str
self.kwargs_str = kwargs_str
_id = hash(self.__class__.__name__ + args_str + kwargs_str)
self._id = _id
def __hash__(self):
return self._id
def __eq__(self, other):
return self._id == other._id
class All(ParticleFilterID, _hoomd.ParticleFilterAll):
def __init__(self):
ParticleFilterID.__init__(self)
_hoomd.ParticleFilterAll(self)
|
f5e36391c253a52fe2bd434caf59c0f5c389cc64
|
tests/base.py
|
tests/base.py
|
import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
|
import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.drop_all()
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
|
Drop db before each test
|
Drop db before each test
|
Python
|
agpl-3.0
|
Meisterschueler/ogn-python,glidernet/ogn-python,glidernet/ogn-python,Meisterschueler/ogn-python,glidernet/ogn-python,glidernet/ogn-python,Meisterschueler/ogn-python,Meisterschueler/ogn-python
|
import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
Drop db before each test
|
import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.drop_all()
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
|
<commit_before>import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
<commit_msg>Drop db before each test<commit_after>
|
import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.drop_all()
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
|
import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
Drop db before each testimport unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.drop_all()
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
|
<commit_before>import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
<commit_msg>Drop db before each test<commit_after>import unittest
import os
os.environ['OGN_CONFIG_MODULE'] = 'config/test.py'
from ogn_python import db # noqa: E402
class TestBaseDB(unittest.TestCase):
@classmethod
def setUpClass(cls):
db.drop_all()
db.session.execute('CREATE EXTENSION IF NOT EXISTS postgis;')
db.session.commit()
db.create_all()
def setUp(self):
pass
def tearDown(self):
db.session.execute("""
DELETE FROM aircraft_beacons;
DELETE FROM receiver_beacons;
DELETE FROM takeoff_landings;
DELETE FROM logbook;
DELETE FROM receiver_coverages;
DELETE FROM device_stats;
DELETE FROM receiver_stats;
DELETE FROM receivers;
DELETE FROM devices;
""")
if __name__ == '__main__':
unittest.main()
|
f1008dc6573661c41361cfe5f3c61a3ee719d6be
|
marketpulse/auth/models.py
|
marketpulse/auth/models.py
|
from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
|
from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
def __unicode__(self):
username = self.mozillians_username or self.username
return unicode(username)
|
Use mozillians_username for unicode representation.
|
Use mozillians_username for unicode representation.
|
Python
|
mpl-2.0
|
akatsoulas/marketpulse,mozilla/marketpulse,mozilla/marketpulse,akatsoulas/marketpulse,mozilla/marketpulse,mozilla/marketpulse,akatsoulas/marketpulse,akatsoulas/marketpulse
|
from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
Use mozillians_username for unicode representation.
|
from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
def __unicode__(self):
username = self.mozillians_username or self.username
return unicode(username)
|
<commit_before>from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
<commit_msg>Use mozillians_username for unicode representation.<commit_after>
|
from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
def __unicode__(self):
username = self.mozillians_username or self.username
return unicode(username)
|
from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
Use mozillians_username for unicode representation.from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
def __unicode__(self):
username = self.mozillians_username or self.username
return unicode(username)
|
<commit_before>from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
<commit_msg>Use mozillians_username for unicode representation.<commit_after>from django.contrib.auth.models import AbstractUser
from django.db.models import fields
class User(AbstractUser):
mozillians_url = fields.URLField()
mozillians_username = fields.CharField(max_length=30, blank=True)
def __unicode__(self):
username = self.mozillians_username or self.username
return unicode(username)
|
50305f63fda1127530650e030f23e92e8a725b8a
|
cgi-bin/user_register.py
|
cgi-bin/user_register.py
|
#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
|
#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User(username, password) values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
|
Fix bug when inserting user.
|
Fix bug when inserting user.
Scheme of table: User has changed.
|
Python
|
mit
|
zhchbin/Yagra,zhchbin/Yagra,zhchbin/Yagra
|
#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
Fix bug when inserting user.
Scheme of table: User has changed.
|
#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User(username, password) values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
|
<commit_before>#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
<commit_msg>Fix bug when inserting user.
Scheme of table: User has changed.<commit_after>
|
#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User(username, password) values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
|
#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
Fix bug when inserting user.
Scheme of table: User has changed.#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User(username, password) values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
|
<commit_before>#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
<commit_msg>Fix bug when inserting user.
Scheme of table: User has changed.<commit_after>#!/usr/bin/python
from MySQLdb import Error
from util import connect_db, dump_response_and_exit
import cgi
import hashlib
import json
import re
import sys
print "Content-type:applicaion/json\r\n\r\n"
form = cgi.FieldStorage()
username = form.getvalue('username')
password = form.getvalue('password')
if username is None or password is None:
dump_response_and_exit(False, 'Missing field: username or password.')
if re.match(r"^[a-zA-Z0-9_.-]+$", username) is None:
dump_response_and_exit(False, 'Invalid username.')
if re.match(r'[A-Za-z0-9@#$%^&+=_.-]{6,}', password) is None:
dump_response_and_exit(False, 'Invalid password.')
try:
con = connect_db()
with con:
cur = con.cursor()
cur.execute("INSERT INTO User(username, password) values (%s, %s)",
(username, hashlib.sha1(password).digest()))
con.commit()
dump_response_and_exit(True, 'Done.')
except Error, e:
if con:
con.rollback()
dump_response_and_exit(False, e[1])
finally:
con.close()
|
46245254cdf9c3f2f6a9c27fe7e089867b4f394f
|
cloudbio/custom/versioncheck.py
|
cloudbio/custom/versioncheck.py
|
"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
out = env.safe_run_output(cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
|
"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
path_safe = "export PATH=$PATH:%s/bin && "
out = env.safe_run_output(path_safe + cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
|
Include env.system_install PATH as part of version checking to work with installed software not on the global PATH. Thanks to James Cuff
|
Include env.system_install PATH as part of version checking to work with installed software not on the global PATH. Thanks to James Cuff
|
Python
|
mit
|
chapmanb/cloudbiolinux,elkingtonmcb/cloudbiolinux,kdaily/cloudbiolinux,elkingtonmcb/cloudbiolinux,kdaily/cloudbiolinux,averagehat/cloudbiolinux,kdaily/cloudbiolinux,chapmanb/cloudbiolinux,joemphilips/cloudbiolinux,AICIDNN/cloudbiolinux,joemphilips/cloudbiolinux,pjotrp/cloudbiolinux,pjotrp/cloudbiolinux,elkingtonmcb/cloudbiolinux,lpantano/cloudbiolinux,joemphilips/cloudbiolinux,kdaily/cloudbiolinux,heuermh/cloudbiolinux,rchekaluk/cloudbiolinux,heuermh/cloudbiolinux,averagehat/cloudbiolinux,AICIDNN/cloudbiolinux,pjotrp/cloudbiolinux,heuermh/cloudbiolinux,rchekaluk/cloudbiolinux,AICIDNN/cloudbiolinux,rchekaluk/cloudbiolinux,rchekaluk/cloudbiolinux,chapmanb/cloudbiolinux,averagehat/cloudbiolinux,chapmanb/cloudbiolinux,joemphilips/cloudbiolinux,pjotrp/cloudbiolinux,elkingtonmcb/cloudbiolinux,averagehat/cloudbiolinux,AICIDNN/cloudbiolinux,lpantano/cloudbiolinux,heuermh/cloudbiolinux,lpantano/cloudbiolinux
|
"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
out = env.safe_run_output(cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
Include env.system_install PATH as part of version checking to work with installed software not on the global PATH. Thanks to James Cuff
|
"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
path_safe = "export PATH=$PATH:%s/bin && "
out = env.safe_run_output(path_safe + cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
|
<commit_before>"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
out = env.safe_run_output(cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
<commit_msg>Include env.system_install PATH as part of version checking to work with installed software not on the global PATH. Thanks to James Cuff<commit_after>
|
"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
path_safe = "export PATH=$PATH:%s/bin && "
out = env.safe_run_output(path_safe + cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
|
"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
out = env.safe_run_output(cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
Include env.system_install PATH as part of version checking to work with installed software not on the global PATH. Thanks to James Cuff"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
path_safe = "export PATH=$PATH:%s/bin && "
out = env.safe_run_output(path_safe + cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
|
<commit_before>"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
out = env.safe_run_output(cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
<commit_msg>Include env.system_install PATH as part of version checking to work with installed software not on the global PATH. Thanks to James Cuff<commit_after>"""Tool specific version checking to identify out of date dependencies.
This provides infrastructure to check version strings against installed
tools, enabling re-installation if a version doesn't match. This is a
lightweight way to avoid out of date dependencies.
"""
from distutils.version import LooseVersion
from fabric.api import quiet
from cloudbio.custom import shared
def _parse_from_stdoutflag(out, flag):
"""Extract version information from a flag in verbose stdout.
"""
for line in out.split("\n") + out.stderr.split("\n"):
if line.find(flag) >= 0:
parts = [x for x in line.split() if not x.startswith(flag)]
return parts[0]
return ""
def up_to_date(env, cmd, version, args=None, stdout_flag=None):
"""Check if the given command is up to date with the provided version.
"""
if shared._executable_not_on_path(cmd):
return False
if args:
cmd = cmd + " " + " ".join(args)
with quiet():
path_safe = "export PATH=$PATH:%s/bin && "
out = env.safe_run_output(path_safe + cmd)
if stdout_flag:
iversion = _parse_from_stdoutflag(out, stdout_flag)
else:
iversion = out.strip()
return LooseVersion(iversion) >= LooseVersion(version)
|
e728d6ebdd101b393f3d87fdfbade2c4c52c5ef1
|
cdent/emitter/perl.py
|
cdent/emitter/perl.py
|
"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use CDent::Class;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
|
"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use Moose;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
|
Use Moose for Perl 5
|
Use Moose for Perl 5
|
Python
|
bsd-2-clause
|
ingydotnet/cdent-py,ingydotnet/cdent-py,ingydotnet/cdent-py,ingydotnet/cdent-py,ingydotnet/cdent-py,ingydotnet/cdent-py,ingydotnet/cdent-py,ingydotnet/cdent-py
|
"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use CDent::Class;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
Use Moose for Perl 5
|
"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use Moose;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
|
<commit_before>"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use CDent::Class;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
<commit_msg>Use Moose for Perl 5<commit_after>
|
"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use Moose;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
|
"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use CDent::Class;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
Use Moose for Perl 5"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use Moose;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
|
<commit_before>"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use CDent::Class;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
<commit_msg>Use Moose for Perl 5<commit_after>"""\
Perl code emitter for C'Dent
"""
from __future__ import absolute_import
from cdent.emitter import Emitter as Base
class Emitter(Base):
LANGUAGE_ID = 'pm'
def emit_includecdent(self, includecdent):
self.writeln('use CDent::Run;')
def emit_class(self, class_):
name = class_.name
self.writeln('package %s;' % name)
self.writeln('use Moose;')
self.writeln()
self.emit(class_.has)
self.writeln()
self.writeln('1;')
def emit_method(self, method):
name = method.name
self.writeln('sub %s {' % name)
self.writeln(' my $self = shift;')
self.emit(method.has, indent=True)
self.writeln('}')
def emit_println(self, println):
self.write('print ', indent=True)
self.emit(println.args)
self.writeln(', "\\n";', indent=False)
def emit_return(self, ret):
self.writeln('return;')
|
2250367b35ccd4074ab758b233df95a5a811475c
|
chainerx/math/misc.py
|
chainerx/math/misc.py
|
import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
|
import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
if a_min is None:
a_min = a.min()
if a_max is None:
a_max = a.max()
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
|
Support None arguments in chainerx.clip and chainerx.ndarray.clip
|
Support None arguments in chainerx.clip and chainerx.ndarray.clip
|
Python
|
mit
|
okuta/chainer,wkentaro/chainer,okuta/chainer,keisuke-umezawa/chainer,keisuke-umezawa/chainer,wkentaro/chainer,pfnet/chainer,chainer/chainer,wkentaro/chainer,keisuke-umezawa/chainer,hvy/chainer,keisuke-umezawa/chainer,chainer/chainer,chainer/chainer,okuta/chainer,niboshi/chainer,niboshi/chainer,niboshi/chainer,wkentaro/chainer,hvy/chainer,hvy/chainer,okuta/chainer,chainer/chainer,niboshi/chainer,hvy/chainer
|
import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
Support None arguments in chainerx.clip and chainerx.ndarray.clip
|
import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
if a_min is None:
a_min = a.min()
if a_max is None:
a_max = a.max()
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
|
<commit_before>import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
<commit_msg>Support None arguments in chainerx.clip and chainerx.ndarray.clip<commit_after>
|
import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
if a_min is None:
a_min = a.min()
if a_max is None:
a_max = a.max()
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
|
import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
Support None arguments in chainerx.clip and chainerx.ndarray.clipimport chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
if a_min is None:
a_min = a.min()
if a_max is None:
a_max = a.max()
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
|
<commit_before>import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
<commit_msg>Support None arguments in chainerx.clip and chainerx.ndarray.clip<commit_after>import chainerx
# TODO(sonots): Implement in C++
def clip(a, a_min, a_max):
"""Clips the values of an array to a given interval.
Given an interval, values outside the interval are clipped to the
interval edges. For example, if an interval of ``[0, 1]`` is specified,
values smaller than 0 become 0, and values larger than 1 become 1.
Args:
a (~chainerx.ndarray): Array containing elements to clip.
a_min (scalar): Maximum value.
a_max (scalar): Minimum value.
Returns:
~chainerx.ndarray: An array with the elements of ``a``, but where
values < ``a_min`` are replaced with ``a_min``,
and those > ``a_max`` with ``a_max``.
Note:
The :class:`~chainerx.ndarray` typed ``a_min`` and ``a_max`` are
not supported yet.
Note:
During backpropagation, this function propagates the gradient
of the output array to the input array ``a``.
.. seealso:: :func:`numpy.clip`
"""
if a_min is None:
a_min = a.min()
if a_max is None:
a_max = a.max()
return -chainerx.maximum(-chainerx.maximum(a, a_min), -a_max)
|
8e4fca866590b4f7aa308d2cc1948b999bb1de8c
|
filebrowser_safe/urls.py
|
filebrowser_safe/urls.py
|
from __future__ import unicode_literals
from django.conf.urls import *
urlpatterns = patterns('',
# filebrowser urls
url(r'^browse/$', 'filebrowser_safe.views.browse', name="fb_browse"),
url(r'^mkdir/', 'filebrowser_safe.views.mkdir', name="fb_mkdir"),
url(r'^upload/', 'filebrowser_safe.views.upload', name="fb_upload"),
url(r'^rename/$', 'filebrowser_safe.views.rename', name="fb_rename"),
url(r'^delete/$', 'filebrowser_safe.views.delete', name="fb_delete"),
url(r'^check_file/$', 'filebrowser_safe.views._check_file', name="fb_check"),
url(r'^upload_file/$', 'filebrowser_safe.views._upload_file', name="fb_do_upload"),
)
|
from __future__ import unicode_literals
from django.conf.urls import url
from filebrowser_safe import views
urlpatterns = [
url(r'^browse/$', views.browse, name="fb_browse"),
url(r'^mkdir/', views.mkdir, name="fb_mkdir"),
url(r'^upload/', views.upload, name="fb_upload"),
url(r'^rename/$', views.rename, name="fb_rename"),
url(r'^delete/$', views.delete, name="fb_delete"),
url(r'^check_file/$', views._check_file, name="fb_check"),
url(r'^upload_file/$', views._upload_file, name="fb_do_upload"),
]
|
Update from deprecated features of urlpatterns.
|
Update from deprecated features of urlpatterns.
|
Python
|
bsd-3-clause
|
ryneeverett/filebrowser-safe,ryneeverett/filebrowser-safe,ryneeverett/filebrowser-safe,ryneeverett/filebrowser-safe
|
from __future__ import unicode_literals
from django.conf.urls import *
urlpatterns = patterns('',
# filebrowser urls
url(r'^browse/$', 'filebrowser_safe.views.browse', name="fb_browse"),
url(r'^mkdir/', 'filebrowser_safe.views.mkdir', name="fb_mkdir"),
url(r'^upload/', 'filebrowser_safe.views.upload', name="fb_upload"),
url(r'^rename/$', 'filebrowser_safe.views.rename', name="fb_rename"),
url(r'^delete/$', 'filebrowser_safe.views.delete', name="fb_delete"),
url(r'^check_file/$', 'filebrowser_safe.views._check_file', name="fb_check"),
url(r'^upload_file/$', 'filebrowser_safe.views._upload_file', name="fb_do_upload"),
)
Update from deprecated features of urlpatterns.
|
from __future__ import unicode_literals
from django.conf.urls import url
from filebrowser_safe import views
urlpatterns = [
url(r'^browse/$', views.browse, name="fb_browse"),
url(r'^mkdir/', views.mkdir, name="fb_mkdir"),
url(r'^upload/', views.upload, name="fb_upload"),
url(r'^rename/$', views.rename, name="fb_rename"),
url(r'^delete/$', views.delete, name="fb_delete"),
url(r'^check_file/$', views._check_file, name="fb_check"),
url(r'^upload_file/$', views._upload_file, name="fb_do_upload"),
]
|
<commit_before>from __future__ import unicode_literals
from django.conf.urls import *
urlpatterns = patterns('',
# filebrowser urls
url(r'^browse/$', 'filebrowser_safe.views.browse', name="fb_browse"),
url(r'^mkdir/', 'filebrowser_safe.views.mkdir', name="fb_mkdir"),
url(r'^upload/', 'filebrowser_safe.views.upload', name="fb_upload"),
url(r'^rename/$', 'filebrowser_safe.views.rename', name="fb_rename"),
url(r'^delete/$', 'filebrowser_safe.views.delete', name="fb_delete"),
url(r'^check_file/$', 'filebrowser_safe.views._check_file', name="fb_check"),
url(r'^upload_file/$', 'filebrowser_safe.views._upload_file', name="fb_do_upload"),
)
<commit_msg>Update from deprecated features of urlpatterns.<commit_after>
|
from __future__ import unicode_literals
from django.conf.urls import url
from filebrowser_safe import views
urlpatterns = [
url(r'^browse/$', views.browse, name="fb_browse"),
url(r'^mkdir/', views.mkdir, name="fb_mkdir"),
url(r'^upload/', views.upload, name="fb_upload"),
url(r'^rename/$', views.rename, name="fb_rename"),
url(r'^delete/$', views.delete, name="fb_delete"),
url(r'^check_file/$', views._check_file, name="fb_check"),
url(r'^upload_file/$', views._upload_file, name="fb_do_upload"),
]
|
from __future__ import unicode_literals
from django.conf.urls import *
urlpatterns = patterns('',
# filebrowser urls
url(r'^browse/$', 'filebrowser_safe.views.browse', name="fb_browse"),
url(r'^mkdir/', 'filebrowser_safe.views.mkdir', name="fb_mkdir"),
url(r'^upload/', 'filebrowser_safe.views.upload', name="fb_upload"),
url(r'^rename/$', 'filebrowser_safe.views.rename', name="fb_rename"),
url(r'^delete/$', 'filebrowser_safe.views.delete', name="fb_delete"),
url(r'^check_file/$', 'filebrowser_safe.views._check_file', name="fb_check"),
url(r'^upload_file/$', 'filebrowser_safe.views._upload_file', name="fb_do_upload"),
)
Update from deprecated features of urlpatterns.from __future__ import unicode_literals
from django.conf.urls import url
from filebrowser_safe import views
urlpatterns = [
url(r'^browse/$', views.browse, name="fb_browse"),
url(r'^mkdir/', views.mkdir, name="fb_mkdir"),
url(r'^upload/', views.upload, name="fb_upload"),
url(r'^rename/$', views.rename, name="fb_rename"),
url(r'^delete/$', views.delete, name="fb_delete"),
url(r'^check_file/$', views._check_file, name="fb_check"),
url(r'^upload_file/$', views._upload_file, name="fb_do_upload"),
]
|
<commit_before>from __future__ import unicode_literals
from django.conf.urls import *
urlpatterns = patterns('',
# filebrowser urls
url(r'^browse/$', 'filebrowser_safe.views.browse', name="fb_browse"),
url(r'^mkdir/', 'filebrowser_safe.views.mkdir', name="fb_mkdir"),
url(r'^upload/', 'filebrowser_safe.views.upload', name="fb_upload"),
url(r'^rename/$', 'filebrowser_safe.views.rename', name="fb_rename"),
url(r'^delete/$', 'filebrowser_safe.views.delete', name="fb_delete"),
url(r'^check_file/$', 'filebrowser_safe.views._check_file', name="fb_check"),
url(r'^upload_file/$', 'filebrowser_safe.views._upload_file', name="fb_do_upload"),
)
<commit_msg>Update from deprecated features of urlpatterns.<commit_after>from __future__ import unicode_literals
from django.conf.urls import url
from filebrowser_safe import views
urlpatterns = [
url(r'^browse/$', views.browse, name="fb_browse"),
url(r'^mkdir/', views.mkdir, name="fb_mkdir"),
url(r'^upload/', views.upload, name="fb_upload"),
url(r'^rename/$', views.rename, name="fb_rename"),
url(r'^delete/$', views.delete, name="fb_delete"),
url(r'^check_file/$', views._check_file, name="fb_check"),
url(r'^upload_file/$', views._upload_file, name="fb_do_upload"),
]
|
852458c7ace8af548ca5da52f56cfddc1a0be2d8
|
service/pixelated/config/logger.py
|
service/pixelated/config/logger.py
|
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel('WARN')
observer.start()
|
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel(logging.WARN)
observer.start()
|
Use logging variable instead of hard coded string to set logging level.
|
Use logging variable instead of hard coded string to set logging level.
|
Python
|
agpl-3.0
|
sw00/pixelated-user-agent,rdoh/pixelated-user-agent,rdoh/pixelated-user-agent,pixelated-project/pixelated-user-agent,pixelated-project/pixelated-user-agent,PuZZleDucK/pixelated-user-agent,pixelated-project/pixelated-user-agent,sw00/pixelated-user-agent,pixelated-project/pixelated-user-agent,rdoh/pixelated-user-agent,pixelated/pixelated-user-agent,SamuelToh/pixelated-user-agent,PuZZleDucK/pixelated-user-agent,rdoh/pixelated-user-agent,rdoh/pixelated-user-agent,PuZZleDucK/pixelated-user-agent,pixelated/pixelated-user-agent,PuZZleDucK/pixelated-user-agent,sw00/pixelated-user-agent,pixelated/pixelated-user-agent,PuZZleDucK/pixelated-user-agent,pixelated/pixelated-user-agent,SamuelToh/pixelated-user-agent,SamuelToh/pixelated-user-agent,sw00/pixelated-user-agent,pixelated/pixelated-user-agent,SamuelToh/pixelated-user-agent,sw00/pixelated-user-agent,SamuelToh/pixelated-user-agent,pixelated-project/pixelated-user-agent
|
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel('WARN')
observer.start()
Use logging variable instead of hard coded string to set logging level.
|
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel(logging.WARN)
observer.start()
|
<commit_before>#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel('WARN')
observer.start()
<commit_msg>Use logging variable instead of hard coded string to set logging level.<commit_after>
|
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel(logging.WARN)
observer.start()
|
#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel('WARN')
observer.start()
Use logging variable instead of hard coded string to set logging level.#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel(logging.WARN)
observer.start()
|
<commit_before>#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel('WARN')
observer.start()
<commit_msg>Use logging variable instead of hard coded string to set logging level.<commit_after>#
# Copyright (c) 2014 ThoughtWorks, Inc.
#
# Pixelated 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.
#
# Pixelated is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Pixelated. If not, see <http://www.gnu.org/licenses/>.
import logging
import os
from twisted.python import log
def init(debug=False):
debug_enabled = debug or os.environ.get('DEBUG', False)
logging_level = logging.DEBUG if debug_enabled else logging.WARN
log_format = "%(asctime)s [%(name)s] %(levelname)s %(message)s"
date_format = '%Y-%m-%d %H:%M:%S'
logging.basicConfig(level=logging_level,
format=log_format,
datefmt=date_format,
filemode='a')
observer = log.PythonLoggingObserver()
logging.getLogger('gnupg').setLevel(logging.WARN)
observer.start()
|
5a09b88399b34ea8a5185fe1bcdff5f3f7ac7619
|
invoke_pytest.py
|
invoke_pytest.py
|
#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import sys
import py
if __name__ == "__main__":
sys.exit(py.test.cmdline.main())
|
#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import os
import sys
import py
if __name__ == "__main__":
os.environ["PYTEST_MD_REPORT_COLOR"] = "text"
sys.exit(py.test.cmdline.main())
|
Add PYTEST_MD_REPORT_COLOR environment variable setting
|
Add PYTEST_MD_REPORT_COLOR environment variable setting
|
Python
|
mit
|
thombashi/pingparsing,thombashi/pingparsing
|
#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import sys
import py
if __name__ == "__main__":
sys.exit(py.test.cmdline.main())
Add PYTEST_MD_REPORT_COLOR environment variable setting
|
#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import os
import sys
import py
if __name__ == "__main__":
os.environ["PYTEST_MD_REPORT_COLOR"] = "text"
sys.exit(py.test.cmdline.main())
|
<commit_before>#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import sys
import py
if __name__ == "__main__":
sys.exit(py.test.cmdline.main())
<commit_msg>Add PYTEST_MD_REPORT_COLOR environment variable setting<commit_after>
|
#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import os
import sys
import py
if __name__ == "__main__":
os.environ["PYTEST_MD_REPORT_COLOR"] = "text"
sys.exit(py.test.cmdline.main())
|
#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import sys
import py
if __name__ == "__main__":
sys.exit(py.test.cmdline.main())
Add PYTEST_MD_REPORT_COLOR environment variable setting#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import os
import sys
import py
if __name__ == "__main__":
os.environ["PYTEST_MD_REPORT_COLOR"] = "text"
sys.exit(py.test.cmdline.main())
|
<commit_before>#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import sys
import py
if __name__ == "__main__":
sys.exit(py.test.cmdline.main())
<commit_msg>Add PYTEST_MD_REPORT_COLOR environment variable setting<commit_after>#!/usr/bin/env python3
"""
Unit tests at Windows environments required to invoke from py module,
because of multiprocessing:
https://py.rtfd.io/en/latest/faq.html?highlight=cmdline#issues-with-py-test-multiprocess-and-setuptools
"""
import os
import sys
import py
if __name__ == "__main__":
os.environ["PYTEST_MD_REPORT_COLOR"] = "text"
sys.exit(py.test.cmdline.main())
|
4a2d59375a94c3863431cbf62638c83c2cc70cfb
|
spec/openpassword/keychain_spec.py
|
spec/openpassword/keychain_spec.py
|
from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
import time
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
class Spy:
def __init__(self):
self.called = False
def callback(self):
self.called = True
|
from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
|
Remove leftover from deleted examples
|
Remove leftover from deleted examples
|
Python
|
mit
|
openpassword/blimey,openpassword/blimey
|
from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
import time
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
class Spy:
def __init__(self):
self.called = False
def callback(self):
self.called = True
Remove leftover from deleted examples
|
from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
|
<commit_before>from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
import time
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
class Spy:
def __init__(self):
self.called = False
def callback(self):
self.called = True
<commit_msg>Remove leftover from deleted examples<commit_after>
|
from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
|
from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
import time
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
class Spy:
def __init__(self):
self.called = False
def callback(self):
self.called = True
Remove leftover from deleted examplesfrom nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
|
<commit_before>from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
import time
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
class Spy:
def __init__(self):
self.called = False
def callback(self):
self.called = True
<commit_msg>Remove leftover from deleted examples<commit_after>from nose.tools import *
from openpassword import EncryptionKey
from openpassword import Keychain
from openpassword.exceptions import InvalidPasswordException
import fudge
class KeychainSpec:
def it_unlocks_the_keychain_with_the_right_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
@raises(InvalidPasswordException)
def it_raises_invalidpasswordexception_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
keychain.unlock('wrongpassword')
def it_fails_to_unlock_with_wrong_password(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt").raises(InvalidPasswordException)
keychain = Keychain(EncryptionKey)
try:
keychain.unlock('wrongpassword')
except:
pass
eq_(keychain.is_locked(), True)
def it_locks_when_lock_is_called(self):
EncryptionKey = fudge.Fake('encryption_key')
EncryptionKey.provides("decrypt")
keychain = Keychain(EncryptionKey)
keychain.unlock('rightpassword')
eq_(keychain.is_locked(), False)
keychain.lock()
eq_(keychain.is_locked(), True)
|
419e06b36c63e8c7fbfdd64dfb7ee5d5654ca3af
|
studentvoice/urls.py
|
studentvoice/urls.py
|
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
|
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^about/$', views.about, name='about'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
|
Add the about page to url.py
|
Add the about page to url.py
|
Python
|
agpl-3.0
|
osamak/student-portal,enjaz/enjaz,osamak/student-portal,osamak/student-portal,osamak/student-portal,enjaz/enjaz,osamak/student-portal,enjaz/enjaz,enjaz/enjaz,enjaz/enjaz
|
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
Add the about page to url.py
|
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^about/$', views.about, name='about'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
|
<commit_before>from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
<commit_msg>Add the about page to url.py<commit_after>
|
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^about/$', views.about, name='about'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
|
from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
Add the about page to url.pyfrom django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^about/$', views.about, name='about'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
|
<commit_before>from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
<commit_msg>Add the about page to url.py<commit_after>from django.conf.urls import patterns, url
from django.views.generic import TemplateView
from studentvoice import views
urlpatterns = patterns('',
url(r'^$', views.home, name='home'),
url(r'^about/$', views.about, name='about'),
url(r'^create/$', views.create, name='create'),
url(r'^search/', views.search, name='search'),
url(r'^(?P<voice_id>\d+)/$', views.show, name='show'),
url(r'^vote/$', views.vote, name='vote'),
url(r'^(?P<voice_id>\d+)/report/$', views.report, name='report'),
url(r'^(?P<voice_id>\d+)/create_comment/$', views.create_comment, name='create_comment'),
url(r'^delete/(?P<voice_id>\d+)/$', views.delete, name='delete'),
url(r'^(?P<voice_id>\d+)/edit/$', views.edit, name='edit'),
url(r'^(?P<voice_id>\d+)/respond/$', views.respond, name='respond'),
url(r'^(?P<voice_id>\d+)/respond/edit/$', views.edit_response, name='edit_response'),
)
|
1b160078c06f65252aa4831ad3b1762684d01acd
|
templatetags/urls.py
|
templatetags/urls.py
|
from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewSafe.as_view(), name='preview_text'),
]
|
from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewText.as_view(), name='preview_text'),
]
|
Fix preview still being slightly different.
|
Fix preview still being slightly different.
|
Python
|
isc
|
ashbc/tgrsite,ashbc/tgrsite,ashbc/tgrsite
|
from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewSafe.as_view(), name='preview_text'),
]
Fix preview still being slightly different.
|
from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewText.as_view(), name='preview_text'),
]
|
<commit_before>from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewSafe.as_view(), name='preview_text'),
]
<commit_msg>Fix preview still being slightly different.<commit_after>
|
from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewText.as_view(), name='preview_text'),
]
|
from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewSafe.as_view(), name='preview_text'),
]
Fix preview still being slightly different.from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewText.as_view(), name='preview_text'),
]
|
<commit_before>from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewSafe.as_view(), name='preview_text'),
]
<commit_msg>Fix preview still being slightly different.<commit_after>from django.urls import path
from . import views
app_name = "utilities"
urlpatterns = [
path('md_preview/', views.MarkdownPreview.as_view(), name='preview'),
path('md_preview_safe/', views.MarkdownPreviewSafe.as_view(), name='preview_safe'),
path('md_preview_newsletter/', views.MarkdownPreviewNewsletter.as_view(), name='preview_newsletter'),
path('md_preview_text/', views.MarkdownPreviewText.as_view(), name='preview_text'),
]
|
e8311fef6dd6905e3cf49f82a5d80ed7ee621ddd
|
conda_build/config.py
|
conda_build/config.py
|
from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 17))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
|
from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 18))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
|
Update default CONDA_NPY to 18
|
Update default CONDA_NPY to 18
|
Python
|
bsd-3-clause
|
mwcraig/conda-build,dan-blanchard/conda-build,shastings517/conda-build,mwcraig/conda-build,frol/conda-build,takluyver/conda-build,sandhujasmine/conda-build,frol/conda-build,takluyver/conda-build,frol/conda-build,takluyver/conda-build,ilastik/conda-build,shastings517/conda-build,sandhujasmine/conda-build,rmcgibbo/conda-build,rmcgibbo/conda-build,rmcgibbo/conda-build,ilastik/conda-build,shastings517/conda-build,dan-blanchard/conda-build,mwcraig/conda-build,dan-blanchard/conda-build,ilastik/conda-build,sandhujasmine/conda-build
|
from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 17))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
Update default CONDA_NPY to 18
|
from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 18))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
|
<commit_before>from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 17))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
<commit_msg>Update default CONDA_NPY to 18<commit_after>
|
from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 18))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
|
from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 17))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
Update default CONDA_NPY to 18from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 18))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
|
<commit_before>from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 17))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
<commit_msg>Update default CONDA_NPY to 18<commit_after>from __future__ import print_function, division, absolute_import
import os
import sys
from os.path import abspath, expanduser, join
import conda.config as cc
CONDA_PY = int(os.getenv('CONDA_PY', cc.default_python.replace('.', '')))
CONDA_NPY = int(os.getenv('CONDA_NPY', 18))
PY3K = int(bool(CONDA_PY >= 30))
if cc.root_writable:
croot = join(cc.root_dir, 'conda-bld')
else:
croot = abspath(expanduser('~/conda-bld'))
build_prefix = join(cc.envs_dirs[0], '_build')
test_prefix = join(cc.envs_dirs[0], '_test')
def _get_python(prefix):
if sys.platform == 'win32':
res = join(prefix, 'python.exe')
else:
res = join(prefix, 'bin/python')
return res
build_python = _get_python(build_prefix)
test_python = _get_python(test_prefix)
def show():
import conda.config as cc
print('CONDA_PY:', CONDA_PY)
print('CONDA_NPY:', CONDA_NPY)
print('subdir:', cc.subdir)
print('croot:', croot)
|
fe41aabf073ce3a02b5af117120d62ffc0324655
|
linked-list/linked-list.py
|
linked-list/linked-list.py
|
# LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
|
# LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
def search(self, position):
counter = 1
current_node = self.head
if position < 1:
return None
while current_node and counter <= position: # go through linked list until you reach input position
if counter == position:
return current_node
current_node = current_node.next
counter += 1
return None # if position larger than length of linked list
|
Add search method for python linked list implementation
|
Add search method for python linked list implementation
|
Python
|
mit
|
derekmpham/interview-prep,derekmpham/interview-prep
|
# LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
Add search method for python linked list implementation
|
# LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
def search(self, position):
counter = 1
current_node = self.head
if position < 1:
return None
while current_node and counter <= position: # go through linked list until you reach input position
if counter == position:
return current_node
current_node = current_node.next
counter += 1
return None # if position larger than length of linked list
|
<commit_before># LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
<commit_msg>Add search method for python linked list implementation<commit_after>
|
# LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
def search(self, position):
counter = 1
current_node = self.head
if position < 1:
return None
while current_node and counter <= position: # go through linked list until you reach input position
if counter == position:
return current_node
current_node = current_node.next
counter += 1
return None # if position larger than length of linked list
|
# LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
Add search method for python linked list implementation# LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
def search(self, position):
counter = 1
current_node = self.head
if position < 1:
return None
while current_node and counter <= position: # go through linked list until you reach input position
if counter == position:
return current_node
current_node = current_node.next
counter += 1
return None # if position larger than length of linked list
|
<commit_before># LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
<commit_msg>Add search method for python linked list implementation<commit_after># LINKED LIST
# define constructor
class Node(object):
def __init__(self, data):
self.data = data
self.next = None
class LinkedList(object):
def __init__(self, head=None):
self.head = head
def add(self, new_node):
current_node = self.head
if self.head:
while current_node.next:
current_node = current_node.next
current_node.next = new_node # add to end of linked list
else:
self.head = new_node
def search(self, position):
counter = 1
current_node = self.head
if position < 1:
return None
while current_node and counter <= position: # go through linked list until you reach input position
if counter == position:
return current_node
current_node = current_node.next
counter += 1
return None # if position larger than length of linked list
|
2f4ace9d1d1489cac1a8ace8b431eec376a02060
|
corehq/apps/couch_sql_migration/management/commands/show_started_migrations.py
|
corehq/apps/couch_sql_migration/management/commands/show_started_migrations.py
|
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
print("")
|
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
try:
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
except Exception as err:
print("Cannot get diff stats: {}".format(err))
print("")
|
Handle error in get diff stats
|
Handle error in get diff stats
|
Python
|
bsd-3-clause
|
dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq
|
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
print("")
Handle error in get diff stats
|
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
try:
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
except Exception as err:
print("Cannot get diff stats: {}".format(err))
print("")
|
<commit_before>from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
print("")
<commit_msg>Handle error in get diff stats<commit_after>
|
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
try:
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
except Exception as err:
print("Cannot get diff stats: {}".format(err))
print("")
|
from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
print("")
Handle error in get diff statsfrom __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
try:
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
except Exception as err:
print("Cannot get diff stats: {}".format(err))
print("")
|
<commit_before>from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
print("")
<commit_msg>Handle error in get diff stats<commit_after>from __future__ import absolute_import
from __future__ import print_function
from __future__ import unicode_literals
from operator import attrgetter
from django.core.management.base import BaseCommand
import six
from corehq.apps.domain_migration_flags.api import get_uncompleted_migrations
from ...progress import COUCH_TO_SQL_SLUG
from .migrate_multiple_domains_from_couch_to_sql import (
format_diff_stats,
get_diff_stats,
)
class Command(BaseCommand):
"""Show domains for which the migration has been strated and not completed"""
def handle(self, **options):
migrations = get_uncompleted_migrations(COUCH_TO_SQL_SLUG)
for status, items in sorted(six.iteritems(migrations)):
print(status)
print("=" * len(status))
print("")
for item in sorted(items, key=attrgetter("domain")):
started = item.started_on
print("{}{}".format(
item.domain,
started.strftime(" (%Y-%m-%d)") if started else "",
))
try:
stats = get_diff_stats(item.domain)
print(format_diff_stats(stats))
except Exception as err:
print("Cannot get diff stats: {}".format(err))
print("")
|
a88d8f6de5e7135b9fdc2ad75a386579bebde07f
|
lcad_to_ldraw.py
|
lcad_to_ldraw.py
|
#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
|
#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
if not (os.path.dirname(sys.argv[1]) == ""):
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
|
Fix to work correctly if we are already in the directory of the lcad file.
|
Fix to work correctly if we are already in the directory of the lcad file.
|
Python
|
mit
|
HazenBabcock/opensdraw
|
#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
Fix to work correctly if we are already in the directory of the lcad file.
|
#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
if not (os.path.dirname(sys.argv[1]) == ""):
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
|
<commit_before>#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
<commit_msg>Fix to work correctly if we are already in the directory of the lcad file.<commit_after>
|
#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
if not (os.path.dirname(sys.argv[1]) == ""):
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
|
#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
Fix to work correctly if we are already in the directory of the lcad file.#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
if not (os.path.dirname(sys.argv[1]) == ""):
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
|
<commit_before>#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
<commit_msg>Fix to work correctly if we are already in the directory of the lcad file.<commit_after>#!/usr/bin/env python
"""
.. module:: lcad_to_ldraw
:synopsis: Generates a ldraw format file from a lcad model.
.. moduleauthor:: Hazen Babcock
"""
import os
import sys
import lcad_language.interpreter as interpreter
if (len(sys.argv)<2):
print "usage: <lcad file> <ldraw file (optional)>"
exit()
# Generate parts.
with open(sys.argv[1]) as fp:
# Change current working directory to the location of the lcad file.
cur_dir = os.getcwd()
if not (os.path.dirname(sys.argv[1]) == ""):
os.chdir(os.path.dirname(sys.argv[1]))
parts = interpreter.execute(fp.read()).getParts()
os.chdir(cur_dir)
print "Model has", len(parts), "parts."
# Save.
if (len(sys.argv) == 3):
ldraw_fname = sys.argv[2]
else:
ldraw_fname = sys.argv[1][:-4] + "dat"
with open(ldraw_fname, "w") as fp:
fp.write("0 // Do not edit, automatically generated by openlcad from " + os.path.basename(sys.argv[1]) + "\n")
for part in parts:
fp.write(part.toLDraw() + "\n")
print "Done."
|
3a8d7ff5f047c7b3476b8dcffa0e6850e952a645
|
docs/examples/http_proxy/set_http_proxy_method.py
|
docs/examples/http_proxy/set_http_proxy_method.py
|
from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
|
from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.connection.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
|
Fix a typo in the example.
|
Fix a typo in the example.
|
Python
|
apache-2.0
|
kater169/libcloud,DimensionDataCBUSydney/libcloud,t-tran/libcloud,Scalr/libcloud,MrBasset/libcloud,watermelo/libcloud,curoverse/libcloud,Kami/libcloud,SecurityCompass/libcloud,Kami/libcloud,pantheon-systems/libcloud,andrewsomething/libcloud,schaubl/libcloud,pantheon-systems/libcloud,jimbobhickville/libcloud,munkiat/libcloud,iPlantCollaborativeOpenSource/libcloud,schaubl/libcloud,Kami/libcloud,JamesGuthrie/libcloud,sahildua2305/libcloud,jimbobhickville/libcloud,iPlantCollaborativeOpenSource/libcloud,aleGpereira/libcloud,mgogoulos/libcloud,SecurityCompass/libcloud,curoverse/libcloud,munkiat/libcloud,sfriesel/libcloud,mbrukman/libcloud,smaffulli/libcloud,mistio/libcloud,niteoweb/libcloud,briancurtin/libcloud,supertom/libcloud,sergiorua/libcloud,cryptickp/libcloud,watermelo/libcloud,vongazman/libcloud,sergiorua/libcloud,samuelchong/libcloud,sfriesel/libcloud,StackPointCloud/libcloud,JamesGuthrie/libcloud,thesquelched/libcloud,cloudControl/libcloud,lochiiconnectivity/libcloud,DimensionDataCBUSydney/libcloud,aviweit/libcloud,t-tran/libcloud,thesquelched/libcloud,jerryblakley/libcloud,techhat/libcloud,cryptickp/libcloud,MrBasset/libcloud,ZuluPro/libcloud,ByteInternet/libcloud,Verizon/libcloud,mbrukman/libcloud,wrigri/libcloud,jimbobhickville/libcloud,Verizon/libcloud,cloudControl/libcloud,wuyuewen/libcloud,iPlantCollaborativeOpenSource/libcloud,mbrukman/libcloud,sahildua2305/libcloud,niteoweb/libcloud,kater169/libcloud,lochiiconnectivity/libcloud,atsaki/libcloud,curoverse/libcloud,smaffulli/libcloud,apache/libcloud,erjohnso/libcloud,mistio/libcloud,apache/libcloud,marcinzaremba/libcloud,ZuluPro/libcloud,ByteInternet/libcloud,mathspace/libcloud,dcorbacho/libcloud,marcinzaremba/libcloud,wido/libcloud,pantheon-systems/libcloud,Itxaka/libcloud,dcorbacho/libcloud,mtekel/libcloud,schaubl/libcloud,munkiat/libcloud,Itxaka/libcloud,mathspace/libcloud,Scalr/libcloud,DimensionDataCBUSydney/libcloud,jerryblakley/libcloud,Cloud-Elasticity-Services/as-libcloud,andrewsomething/libcloud,Itxaka/libcloud,NexusIS/libcloud,atsaki/libcloud,Cloud-Elasticity-Services/as-libcloud,jerryblakley/libcloud,techhat/libcloud,aleGpereira/libcloud,techhat/libcloud,samuelchong/libcloud,supertom/libcloud,cloudControl/libcloud,niteoweb/libcloud,sfriesel/libcloud,mgogoulos/libcloud,t-tran/libcloud,Verizon/libcloud,marcinzaremba/libcloud,carletes/libcloud,wuyuewen/libcloud,samuelchong/libcloud,cryptickp/libcloud,mathspace/libcloud,thesquelched/libcloud,mtekel/libcloud,wrigri/libcloud,sergiorua/libcloud,vongazman/libcloud,carletes/libcloud,smaffulli/libcloud,vongazman/libcloud,mistio/libcloud,sahildua2305/libcloud,wuyuewen/libcloud,dcorbacho/libcloud,illfelder/libcloud,lochiiconnectivity/libcloud,atsaki/libcloud,aviweit/libcloud,pquentin/libcloud,carletes/libcloud,ZuluPro/libcloud,wido/libcloud,ByteInternet/libcloud,briancurtin/libcloud,pquentin/libcloud,mgogoulos/libcloud,illfelder/libcloud,apache/libcloud,aviweit/libcloud,erjohnso/libcloud,andrewsomething/libcloud,Scalr/libcloud,aleGpereira/libcloud,MrBasset/libcloud,mtekel/libcloud,pquentin/libcloud,watermelo/libcloud,supertom/libcloud,StackPointCloud/libcloud,Cloud-Elasticity-Services/as-libcloud,NexusIS/libcloud,briancurtin/libcloud,erjohnso/libcloud,JamesGuthrie/libcloud,SecurityCompass/libcloud,wrigri/libcloud,StackPointCloud/libcloud,kater169/libcloud,NexusIS/libcloud,wido/libcloud,illfelder/libcloud
|
from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
Fix a typo in the example.
|
from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.connection.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
|
<commit_before>from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
<commit_msg>Fix a typo in the example.<commit_after>
|
from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.connection.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
|
from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
Fix a typo in the example.from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.connection.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
|
<commit_before>from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
<commit_msg>Fix a typo in the example.<commit_after>from pprint import pprint
from libcloud.compute.types import Provider
from libcloud.compute.providers import get_driver
PROXY_URL = 'http://<proxy hostname>:<proxy port>'
cls = get_driver(Provider.RACKSPACE)
driver = cls('username', 'api key', region='ord')
driver.connection.set_http_proxy(proxy_url=PROXY_URL)
pprint(driver.list_nodes())
|
ff21cb8c844e235d5d9b0c9e37578196e0f02768
|
takePicture.py
|
takePicture.py
|
import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 50:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
|
import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 15:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
|
Reduce picture loop to 15 pictures
|
Reduce picture loop to 15 pictures
|
Python
|
mit
|
jwarshaw/RaspberryDrive
|
import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 50:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
Reduce picture loop to 15 pictures
|
import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 15:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
|
<commit_before>import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 50:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
<commit_msg>Reduce picture loop to 15 pictures<commit_after>
|
import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 15:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
|
import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 50:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
Reduce picture loop to 15 picturesimport picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 15:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
|
<commit_before>import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 50:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
<commit_msg>Reduce picture loop to 15 pictures<commit_after>import picamera as p
import os
import time
os.chdir('/home/pi/Desktop')
cam = p.PiCamera()
cam.resolution = (320,240)
cam.hflip = True
cam.vflip = True
x = 0
while x < 15:
os.unlink('gregTest.jpg')
img = cam.capture('tempGregTest.jpg')
oc.rename('gregTempTest.jpg', 'gregTest.jpg')
time.sleep(.25)
x +=1
exit()
|
f7b471858e89fe07b78dd3853d4351dfa83cac49
|
placidity/plugin_loader.py
|
placidity/plugin_loader.py
|
class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes[plugin.name]
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
|
class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes.get(plugin.name)
if not plugin_class:
print 'Plugin file is missing proper class!', plugin.name, plugin_file.classes
continue
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
|
Make plugin loader more robust
|
Make plugin loader more robust
|
Python
|
mit
|
bebraw/Placidity
|
class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes[plugin.name]
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
Make plugin loader more robust
|
class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes.get(plugin.name)
if not plugin_class:
print 'Plugin file is missing proper class!', plugin.name, plugin_file.classes
continue
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
|
<commit_before>class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes[plugin.name]
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
<commit_msg>Make plugin loader more robust<commit_after>
|
class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes.get(plugin.name)
if not plugin_class:
print 'Plugin file is missing proper class!', plugin.name, plugin_file.classes
continue
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
|
class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes[plugin.name]
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
Make plugin loader more robustclass PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes.get(plugin.name)
if not plugin_class:
print 'Plugin file is missing proper class!', plugin.name, plugin_file.classes
continue
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
|
<commit_before>class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes[plugin.name]
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
<commit_msg>Make plugin loader more robust<commit_after>class PluginLoader:
def load(self, directory):
ret = []
for plugin in directory.children:
plugin_file = plugin.find(name=plugin.name, type='py')
if not plugin_file:
continue
plugin_class = plugin_file.classes.get(plugin.name)
if not plugin_class:
print 'Plugin file is missing proper class!', plugin.name, plugin_file.classes
continue
self._check_attributes(plugin_class)
plugin_instance = plugin_class()
ret.append(plugin_instance)
return ret
def _check_attributes(self, klass):
self._check_aliases(klass)
self._check_matches(klass)
self._check_priority(klass)
def _check_aliases(self, klass):
self._check_attribute(klass, 'aliases', '')
def _check_matches(self, klass):
def matches(self, expression):
if isinstance(self.aliases, str):
return expression == self.aliases
return expression in self.aliases
self._check_attribute(klass, 'matches', matches)
def _check_priority(self, klass):
self._check_attribute(klass, 'priority', 'normal')
if klass.priority not in ('low', 'normal', 'high'):
klass.priority = 'normal'
def _check_attribute(self, klass, attribute, value):
if not hasattr(klass, attribute):
setattr(klass, attribute, value)
|
fd0c556baa12de2fc22f3f4829d683556ca363a7
|
manager/trackmon_manager.py
|
manager/trackmon_manager.py
|
import sys
def main():
if "-install" in sys.argv:
print("Installing everything")
elif "-installapi" in sys.argv:
print("Installing API backend only")
elif "-installdb" in sys.argv:
print("Installing database only")
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
if __name__ == "__main__":
main()
|
import sys
import os
from subprocess import call
import urllib.request
import json
#from pprint import pprint
# User needs to install postgres first
trackmon_server_api_info = "https://api.github.com/repos/paulkramme/roverpi/releases/latest"
def download(url, path):
with urllib.request.urlopen(url) as response, open(path, 'wb') as output:
shutil.copyfileobj(response, output)
def get_dl_from_gh_api(url):
response = urllib.request.urlopen(url)
data = response.read()
jsonresp = json.loads(data.decode('utf-8'))
#pprint(json)
for asset in jsonresp["assets"]:
print(str(asset["name"])) # BUG: Nothing prints here...
print("Done.")
def main():
if "-install" in sys.argv:
print("Installing everything")
# TODO: Verify that postgres exist
# TODO: Download trackmon server
get_dl_from_gh_api(trackmon_server_api_info)
elif "-installapi" in sys.argv:
print("Installing API backend only")
# TODO: Download trackmon server
elif "-installdb" in sys.argv:
print("Installing database only")
# TODO: Verify that postgres exist
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
# TODO: Later...
elif "-update" in sys.argv:
print("Updating components")
if __name__ == "__main__":
main()
input()
|
Add many todos and basic version download
|
Add many todos and basic version download
|
Python
|
bsd-2-clause
|
trackmon/trackmon-server,trackmon/trackmon-server
|
import sys
def main():
if "-install" in sys.argv:
print("Installing everything")
elif "-installapi" in sys.argv:
print("Installing API backend only")
elif "-installdb" in sys.argv:
print("Installing database only")
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
if __name__ == "__main__":
main()
Add many todos and basic version download
|
import sys
import os
from subprocess import call
import urllib.request
import json
#from pprint import pprint
# User needs to install postgres first
trackmon_server_api_info = "https://api.github.com/repos/paulkramme/roverpi/releases/latest"
def download(url, path):
with urllib.request.urlopen(url) as response, open(path, 'wb') as output:
shutil.copyfileobj(response, output)
def get_dl_from_gh_api(url):
response = urllib.request.urlopen(url)
data = response.read()
jsonresp = json.loads(data.decode('utf-8'))
#pprint(json)
for asset in jsonresp["assets"]:
print(str(asset["name"])) # BUG: Nothing prints here...
print("Done.")
def main():
if "-install" in sys.argv:
print("Installing everything")
# TODO: Verify that postgres exist
# TODO: Download trackmon server
get_dl_from_gh_api(trackmon_server_api_info)
elif "-installapi" in sys.argv:
print("Installing API backend only")
# TODO: Download trackmon server
elif "-installdb" in sys.argv:
print("Installing database only")
# TODO: Verify that postgres exist
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
# TODO: Later...
elif "-update" in sys.argv:
print("Updating components")
if __name__ == "__main__":
main()
input()
|
<commit_before>import sys
def main():
if "-install" in sys.argv:
print("Installing everything")
elif "-installapi" in sys.argv:
print("Installing API backend only")
elif "-installdb" in sys.argv:
print("Installing database only")
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
if __name__ == "__main__":
main()
<commit_msg>Add many todos and basic version download<commit_after>
|
import sys
import os
from subprocess import call
import urllib.request
import json
#from pprint import pprint
# User needs to install postgres first
trackmon_server_api_info = "https://api.github.com/repos/paulkramme/roverpi/releases/latest"
def download(url, path):
with urllib.request.urlopen(url) as response, open(path, 'wb') as output:
shutil.copyfileobj(response, output)
def get_dl_from_gh_api(url):
response = urllib.request.urlopen(url)
data = response.read()
jsonresp = json.loads(data.decode('utf-8'))
#pprint(json)
for asset in jsonresp["assets"]:
print(str(asset["name"])) # BUG: Nothing prints here...
print("Done.")
def main():
if "-install" in sys.argv:
print("Installing everything")
# TODO: Verify that postgres exist
# TODO: Download trackmon server
get_dl_from_gh_api(trackmon_server_api_info)
elif "-installapi" in sys.argv:
print("Installing API backend only")
# TODO: Download trackmon server
elif "-installdb" in sys.argv:
print("Installing database only")
# TODO: Verify that postgres exist
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
# TODO: Later...
elif "-update" in sys.argv:
print("Updating components")
if __name__ == "__main__":
main()
input()
|
import sys
def main():
if "-install" in sys.argv:
print("Installing everything")
elif "-installapi" in sys.argv:
print("Installing API backend only")
elif "-installdb" in sys.argv:
print("Installing database only")
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
if __name__ == "__main__":
main()
Add many todos and basic version downloadimport sys
import os
from subprocess import call
import urllib.request
import json
#from pprint import pprint
# User needs to install postgres first
trackmon_server_api_info = "https://api.github.com/repos/paulkramme/roverpi/releases/latest"
def download(url, path):
with urllib.request.urlopen(url) as response, open(path, 'wb') as output:
shutil.copyfileobj(response, output)
def get_dl_from_gh_api(url):
response = urllib.request.urlopen(url)
data = response.read()
jsonresp = json.loads(data.decode('utf-8'))
#pprint(json)
for asset in jsonresp["assets"]:
print(str(asset["name"])) # BUG: Nothing prints here...
print("Done.")
def main():
if "-install" in sys.argv:
print("Installing everything")
# TODO: Verify that postgres exist
# TODO: Download trackmon server
get_dl_from_gh_api(trackmon_server_api_info)
elif "-installapi" in sys.argv:
print("Installing API backend only")
# TODO: Download trackmon server
elif "-installdb" in sys.argv:
print("Installing database only")
# TODO: Verify that postgres exist
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
# TODO: Later...
elif "-update" in sys.argv:
print("Updating components")
if __name__ == "__main__":
main()
input()
|
<commit_before>import sys
def main():
if "-install" in sys.argv:
print("Installing everything")
elif "-installapi" in sys.argv:
print("Installing API backend only")
elif "-installdb" in sys.argv:
print("Installing database only")
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
if __name__ == "__main__":
main()
<commit_msg>Add many todos and basic version download<commit_after>import sys
import os
from subprocess import call
import urllib.request
import json
#from pprint import pprint
# User needs to install postgres first
trackmon_server_api_info = "https://api.github.com/repos/paulkramme/roverpi/releases/latest"
def download(url, path):
with urllib.request.urlopen(url) as response, open(path, 'wb') as output:
shutil.copyfileobj(response, output)
def get_dl_from_gh_api(url):
response = urllib.request.urlopen(url)
data = response.read()
jsonresp = json.loads(data.decode('utf-8'))
#pprint(json)
for asset in jsonresp["assets"]:
print(str(asset["name"])) # BUG: Nothing prints here...
print("Done.")
def main():
if "-install" in sys.argv:
print("Installing everything")
# TODO: Verify that postgres exist
# TODO: Download trackmon server
get_dl_from_gh_api(trackmon_server_api_info)
elif "-installapi" in sys.argv:
print("Installing API backend only")
# TODO: Download trackmon server
elif "-installdb" in sys.argv:
print("Installing database only")
# TODO: Verify that postgres exist
elif "-installfrontend" in sys.argv:
print("Installing frontend only")
# TODO: Later...
elif "-update" in sys.argv:
print("Updating components")
if __name__ == "__main__":
main()
input()
|
ba4eace22eb2379a5a0d8a79615892edd58b1f49
|
mezzanine/core/sitemaps.py
|
mezzanine/core/sitemaps.py
|
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = []
item_urls = set()
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
url = item.get_absolute_url()
# check if the url of that item was already seen
# (this might happen for Page items and subclasses of Page like RichTextPage)
if not url in item_urls:
items.append(item)
item_urls.add(url)
return items
|
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = {}
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
items[item.get_absolute_url()] = item
return items.values()
|
Clean up sitemap URL handling.
|
Clean up sitemap URL handling.
|
Python
|
bsd-2-clause
|
Cajoline/mezzanine,guibernardino/mezzanine,agepoly/mezzanine,sjuxax/mezzanine,vladir/mezzanine,Cicero-Zhao/mezzanine,stbarnabas/mezzanine,sjdines/mezzanine,viaregio/mezzanine,wbtuomela/mezzanine,biomassives/mezzanine,frankchin/mezzanine,orlenko/plei,dekomote/mezzanine-modeltranslation-backport,batpad/mezzanine,mush42/mezzanine,vladir/mezzanine,industrydive/mezzanine,scarcry/snm-mezzanine,nikolas/mezzanine,geodesign/mezzanine,PegasusWang/mezzanine,Cajoline/mezzanine,stephenmcd/mezzanine,saintbird/mezzanine,dovydas/mezzanine,theclanks/mezzanine,wrwrwr/mezzanine,jerivas/mezzanine,Skytorn86/mezzanine,theclanks/mezzanine,vladir/mezzanine,molokov/mezzanine,stbarnabas/mezzanine,adrian-the-git/mezzanine,ZeroXn/mezzanine,promil23/mezzanine,biomassives/mezzanine,spookylukey/mezzanine,saintbird/mezzanine,sjuxax/mezzanine,readevalprint/mezzanine,christianwgd/mezzanine,webounty/mezzanine,gbosh/mezzanine,industrydive/mezzanine,fusionbox/mezzanine,tuxinhang1989/mezzanine,readevalprint/mezzanine,wbtuomela/mezzanine,emile2016/mezzanine,ZeroXn/mezzanine,viaregio/mezzanine,wbtuomela/mezzanine,joshcartme/mezzanine,dustinrb/mezzanine,Kniyl/mezzanine,gradel/mezzanine,theclanks/mezzanine,frankier/mezzanine,wyzex/mezzanine,PegasusWang/mezzanine,eino-makitalo/mezzanine,orlenko/sfpirg,eino-makitalo/mezzanine,nikolas/mezzanine,PegasusWang/mezzanine,promil23/mezzanine,sjdines/mezzanine,guibernardino/mezzanine,sjdines/mezzanine,damnfine/mezzanine,Cicero-Zhao/mezzanine,saintbird/mezzanine,scarcry/snm-mezzanine,jjz/mezzanine,wyzex/mezzanine,spookylukey/mezzanine,AlexHill/mezzanine,webounty/mezzanine,webounty/mezzanine,ryneeverett/mezzanine,batpad/mezzanine,jerivas/mezzanine,frankier/mezzanine,jerivas/mezzanine,dekomote/mezzanine-modeltranslation-backport,agepoly/mezzanine,orlenko/plei,orlenko/sfpirg,frankchin/mezzanine,jjz/mezzanine,SoLoHiC/mezzanine,molokov/mezzanine,dsanders11/mezzanine,orlenko/sfpirg,cccs-web/mezzanine,douglaskastle/mezzanine,wrwrwr/mezzanine,Kniyl/mezzanine,gradel/mezzanine,viaregio/mezzanine,adrian-the-git/mezzanine,dovydas/mezzanine,SoLoHiC/mezzanine,nikolas/mezzanine,geodesign/mezzanine,mush42/mezzanine,douglaskastle/mezzanine,gradel/mezzanine,eino-makitalo/mezzanine,douglaskastle/mezzanine,stephenmcd/mezzanine,ZeroXn/mezzanine,joshcartme/mezzanine,biomassives/mezzanine,dsanders11/mezzanine,tuxinhang1989/mezzanine,AlexHill/mezzanine,frankchin/mezzanine,damnfine/mezzanine,mush42/mezzanine,scarcry/snm-mezzanine,dsanders11/mezzanine,orlenko/plei,dustinrb/mezzanine,Skytorn86/mezzanine,frankier/mezzanine,molokov/mezzanine,adrian-the-git/mezzanine,joshcartme/mezzanine,gbosh/mezzanine,sjuxax/mezzanine,emile2016/mezzanine,gbosh/mezzanine,industrydive/mezzanine,Kniyl/mezzanine,ryneeverett/mezzanine,dekomote/mezzanine-modeltranslation-backport,fusionbox/mezzanine,readevalprint/mezzanine,geodesign/mezzanine,agepoly/mezzanine,SoLoHiC/mezzanine,stephenmcd/mezzanine,Skytorn86/mezzanine,dustinrb/mezzanine,wyzex/mezzanine,promil23/mezzanine,jjz/mezzanine,dovydas/mezzanine,Cajoline/mezzanine,cccs-web/mezzanine,spookylukey/mezzanine,tuxinhang1989/mezzanine,christianwgd/mezzanine,ryneeverett/mezzanine,christianwgd/mezzanine,damnfine/mezzanine,emile2016/mezzanine
|
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = []
item_urls = set()
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
url = item.get_absolute_url()
# check if the url of that item was already seen
# (this might happen for Page items and subclasses of Page like RichTextPage)
if not url in item_urls:
items.append(item)
item_urls.add(url)
return items
Clean up sitemap URL handling.
|
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = {}
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
items[item.get_absolute_url()] = item
return items.values()
|
<commit_before>
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = []
item_urls = set()
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
url = item.get_absolute_url()
# check if the url of that item was already seen
# (this might happen for Page items and subclasses of Page like RichTextPage)
if not url in item_urls:
items.append(item)
item_urls.add(url)
return items
<commit_msg>Clean up sitemap URL handling.<commit_after>
|
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = {}
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
items[item.get_absolute_url()] = item
return items.values()
|
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = []
item_urls = set()
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
url = item.get_absolute_url()
# check if the url of that item was already seen
# (this might happen for Page items and subclasses of Page like RichTextPage)
if not url in item_urls:
items.append(item)
item_urls.add(url)
return items
Clean up sitemap URL handling.
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = {}
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
items[item.get_absolute_url()] = item
return items.values()
|
<commit_before>
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = []
item_urls = set()
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
url = item.get_absolute_url()
# check if the url of that item was already seen
# (this might happen for Page items and subclasses of Page like RichTextPage)
if not url in item_urls:
items.append(item)
item_urls.add(url)
return items
<commit_msg>Clean up sitemap URL handling.<commit_after>
from django.contrib.sitemaps import Sitemap
from django.db.models import get_models
from mezzanine.core.models import Displayable
class DisplayableSitemap(Sitemap):
"""
Sitemap class for Django's sitemaps framework that returns
all published items for models that subclass ``Displayable``.
"""
def items(self):
"""
Return all published items for models that subclass
``Displayable``.
"""
items = {}
for model in get_models():
if issubclass(model, Displayable):
for item in model.objects.published():
items[item.get_absolute_url()] = item
return items.values()
|
d1da755f10d4287d1cfbec3a6d29d9961125bbce
|
plugins/tff_backend/plugin_consts.py
|
plugins/tff_backend/plugin_consts.py
|
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83
}
|
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
'BTC': 'bitcoin',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83,
'BTC': .0011,
}
|
Add BTC to possible currencies
|
Add BTC to possible currencies
|
Python
|
bsd-3-clause
|
threefoldfoundation/app_backend,threefoldfoundation/app_backend,threefoldfoundation/app_backend,threefoldfoundation/app_backend
|
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83
}
Add BTC to possible currencies
|
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
'BTC': 'bitcoin',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83,
'BTC': .0011,
}
|
<commit_before># -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83
}
<commit_msg>Add BTC to possible currencies<commit_after>
|
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
'BTC': 'bitcoin',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83,
'BTC': .0011,
}
|
# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83
}
Add BTC to possible currencies# -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
'BTC': 'bitcoin',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83,
'BTC': .0011,
}
|
<commit_before># -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83
}
<commit_msg>Add BTC to possible currencies<commit_after># -*- coding: utf-8 -*-
# Copyright 2017 GIG Technology NV
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# @@license_version:1.3@@
NAMESPACE = u'tff_backend'
KEY_ALGORITHM = u'ed25519'
KEY_NAME = u'threefold'
THREEFOLD_APP_ID = u'em-be-threefold-token'
FULL_CURRENCY_NAMES = {
'USD': 'dollar',
'EUR': 'euro',
'YEN': 'yen',
'UAE': 'dirham',
'GBP': 'pound',
'BTC': 'bitcoin',
}
CURRENCY_RATES = {
'USD': 5.0,
'EUR': 4.2,
'YEN': 543.6,
'UAE': 18.6,
'GBP': 3.83,
'BTC': .0011,
}
|
9c8dbde9b39f6fcd713a7d118dcd613cc48cf54e
|
astropy/tests/tests/test_run_tests.py
|
astropy/tests/tests/test_run_tests.py
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import sys
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
if sys.version_info[:2] == (3, 3):
with pytest.raises(DeprecationWarning):
'{0:s}'.format(object())
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import warnings
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
with pytest.raises(DeprecationWarning):
warnings.warn('test warning', DeprecationWarning)
|
Test that deprecation exceptions are working differently, after suggestion by @embray
|
Test that deprecation exceptions are working differently, after
suggestion by @embray
|
Python
|
bsd-3-clause
|
larrybradley/astropy,aleksandr-bakanov/astropy,DougBurke/astropy,stargaser/astropy,DougBurke/astropy,joergdietrich/astropy,kelle/astropy,mhvk/astropy,funbaker/astropy,saimn/astropy,lpsinger/astropy,pllim/astropy,dhomeier/astropy,StuartLittlefair/astropy,lpsinger/astropy,larrybradley/astropy,aleksandr-bakanov/astropy,dhomeier/astropy,dhomeier/astropy,mhvk/astropy,kelle/astropy,saimn/astropy,larrybradley/astropy,StuartLittlefair/astropy,dhomeier/astropy,bsipocz/astropy,astropy/astropy,kelle/astropy,MSeifert04/astropy,funbaker/astropy,astropy/astropy,DougBurke/astropy,tbabej/astropy,tbabej/astropy,stargaser/astropy,AustereCuriosity/astropy,saimn/astropy,lpsinger/astropy,joergdietrich/astropy,joergdietrich/astropy,StuartLittlefair/astropy,astropy/astropy,AustereCuriosity/astropy,bsipocz/astropy,saimn/astropy,astropy/astropy,stargaser/astropy,funbaker/astropy,stargaser/astropy,DougBurke/astropy,mhvk/astropy,astropy/astropy,bsipocz/astropy,dhomeier/astropy,MSeifert04/astropy,joergdietrich/astropy,kelle/astropy,joergdietrich/astropy,kelle/astropy,larrybradley/astropy,AustereCuriosity/astropy,StuartLittlefair/astropy,lpsinger/astropy,StuartLittlefair/astropy,aleksandr-bakanov/astropy,tbabej/astropy,aleksandr-bakanov/astropy,pllim/astropy,pllim/astropy,larrybradley/astropy,pllim/astropy,AustereCuriosity/astropy,funbaker/astropy,mhvk/astropy,bsipocz/astropy,tbabej/astropy,pllim/astropy,saimn/astropy,MSeifert04/astropy,MSeifert04/astropy,tbabej/astropy,mhvk/astropy,AustereCuriosity/astropy,lpsinger/astropy
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import sys
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
if sys.version_info[:2] == (3, 3):
with pytest.raises(DeprecationWarning):
'{0:s}'.format(object())
Test that deprecation exceptions are working differently, after
suggestion by @embray
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import warnings
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
with pytest.raises(DeprecationWarning):
warnings.warn('test warning', DeprecationWarning)
|
<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import sys
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
if sys.version_info[:2] == (3, 3):
with pytest.raises(DeprecationWarning):
'{0:s}'.format(object())
<commit_msg>Test that deprecation exceptions are working differently, after
suggestion by @embray<commit_after>
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import warnings
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
with pytest.raises(DeprecationWarning):
warnings.warn('test warning', DeprecationWarning)
|
# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import sys
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
if sys.version_info[:2] == (3, 3):
with pytest.raises(DeprecationWarning):
'{0:s}'.format(object())
Test that deprecation exceptions are working differently, after
suggestion by @embray# Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import warnings
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
with pytest.raises(DeprecationWarning):
warnings.warn('test warning', DeprecationWarning)
|
<commit_before># Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import sys
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
if sys.version_info[:2] == (3, 3):
with pytest.raises(DeprecationWarning):
'{0:s}'.format(object())
<commit_msg>Test that deprecation exceptions are working differently, after
suggestion by @embray<commit_after># Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
# test helper.run_tests function
import warnings
from .. import helper
from ... import _get_test_runner
from .. helper import pytest
# run_tests should raise ValueError when asked to run on a module it can't find
def test_module_not_found():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests('fake.module')
# run_tests should raise ValueError when passed an invalid pastebin= option
def test_pastebin_keyword():
with helper.pytest.raises(ValueError):
_get_test_runner().run_tests(pastebin='not_an_option')
# tests that tests are only run in Python 3 out of the 2to3'd build (otherwise
# a syntax error would occur)
try:
from .run_after_2to3 import test_run_after_2to3
except SyntaxError:
def test_run_after_2to3():
helper.pytest.fail("Not running the 2to3'd tests!")
def test_deprecation_warning():
with pytest.raises(DeprecationWarning):
warnings.warn('test warning', DeprecationWarning)
|
24093369bb1dbd2e9034db9425920ffdc14ee070
|
abusehelper/bots/abusech/feodoccbot.py
|
abusehelper/bots/abusech/feodoccbot.py
|
"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
|
"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "status":
yield "status", value
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
|
Include status information in abuse.ch's Feodo C&C feed
|
Include status information in abuse.ch's Feodo C&C feed
|
Python
|
mit
|
abusesa/abusehelper
|
"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
Include status information in abuse.ch's Feodo C&C feed
|
"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "status":
yield "status", value
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
|
<commit_before>"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
<commit_msg>Include status information in abuse.ch's Feodo C&C feed<commit_after>
|
"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "status":
yield "status", value
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
|
"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
Include status information in abuse.ch's Feodo C&C feed"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "status":
yield "status", value
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
|
<commit_before>"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
<commit_msg>Include status information in abuse.ch's Feodo C&C feed<commit_after>"""
abuse.ch Feodo RSS feed bot.
Maintainer: AbuseSA team <[email protected]>
"""
from abusehelper.core import bot
from . import host_or_ip, split_description, AbuseCHFeedBot
class FeodoCcBot(AbuseCHFeedBot):
feed_type = "c&c"
feed_name = "feodo c&c"
feeds = bot.ListParam(default=["https://feodotracker.abuse.ch/feodotracker.rss"])
# The timestamp in the title appears to be the firstseen timestamp,
# skip including it as the "source time".
parse_title = None
def parse_description(self, description):
got_version = False
for key, value in split_description(description):
if key == "version":
yield "malware family", "feodo." + value.strip().lower()
got_version = True
elif key == "status":
yield "status", value
elif key == "host":
yield host_or_ip(value)
if not got_version:
yield "malware family", "feodo"
if __name__ == "__main__":
FeodoCcBot.from_command_line().execute()
|
efd1841fb904e30ac0b87b7c7d019f2745452cb2
|
test_output.py
|
test_output.py
|
#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
if __name__ == '__main__':
unittest.main()
|
#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
def _assert_resolve_tco(self, url, expected):
result = self.run_safari_rs('resolve', url)
assert result.rc == 0
assert result.stderr == ''
assert result.stdout == expected
def test_resolve_single_redirect(self):
self._assert_resolve_tco('https://t.co/2pciHpqpwC', 'https://donmelton.com/2013/06/04/remembering-penny/')
def test_resolve_multiple_redirect(self):
self._assert_resolve_tco('https://t.co/oSJaiNlIP6', 'https://bitly.com/blog/backlinking-strategy/')
def test_resolve_no_redirect(self):
self._assert_resolve_tco('https://example.org/', 'https://example.org/')
if __name__ == '__main__':
unittest.main()
|
Add some tests for the URL resolver
|
Add some tests for the URL resolver
|
Python
|
mit
|
alexwlchan/safari.rs,alexwlchan/safari.rs
|
#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
if __name__ == '__main__':
unittest.main()
Add some tests for the URL resolver
|
#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
def _assert_resolve_tco(self, url, expected):
result = self.run_safari_rs('resolve', url)
assert result.rc == 0
assert result.stderr == ''
assert result.stdout == expected
def test_resolve_single_redirect(self):
self._assert_resolve_tco('https://t.co/2pciHpqpwC', 'https://donmelton.com/2013/06/04/remembering-penny/')
def test_resolve_multiple_redirect(self):
self._assert_resolve_tco('https://t.co/oSJaiNlIP6', 'https://bitly.com/blog/backlinking-strategy/')
def test_resolve_no_redirect(self):
self._assert_resolve_tco('https://example.org/', 'https://example.org/')
if __name__ == '__main__':
unittest.main()
|
<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
if __name__ == '__main__':
unittest.main()
<commit_msg>Add some tests for the URL resolver<commit_after>
|
#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
def _assert_resolve_tco(self, url, expected):
result = self.run_safari_rs('resolve', url)
assert result.rc == 0
assert result.stderr == ''
assert result.stdout == expected
def test_resolve_single_redirect(self):
self._assert_resolve_tco('https://t.co/2pciHpqpwC', 'https://donmelton.com/2013/06/04/remembering-penny/')
def test_resolve_multiple_redirect(self):
self._assert_resolve_tco('https://t.co/oSJaiNlIP6', 'https://bitly.com/blog/backlinking-strategy/')
def test_resolve_no_redirect(self):
self._assert_resolve_tco('https://example.org/', 'https://example.org/')
if __name__ == '__main__':
unittest.main()
|
#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
if __name__ == '__main__':
unittest.main()
Add some tests for the URL resolver#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
def _assert_resolve_tco(self, url, expected):
result = self.run_safari_rs('resolve', url)
assert result.rc == 0
assert result.stderr == ''
assert result.stdout == expected
def test_resolve_single_redirect(self):
self._assert_resolve_tco('https://t.co/2pciHpqpwC', 'https://donmelton.com/2013/06/04/remembering-penny/')
def test_resolve_multiple_redirect(self):
self._assert_resolve_tco('https://t.co/oSJaiNlIP6', 'https://bitly.com/blog/backlinking-strategy/')
def test_resolve_no_redirect(self):
self._assert_resolve_tco('https://example.org/', 'https://example.org/')
if __name__ == '__main__':
unittest.main()
|
<commit_before>#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
if __name__ == '__main__':
unittest.main()
<commit_msg>Add some tests for the URL resolver<commit_after>#!/usr/bin/env python
# -*- encoding: utf-8
"""
These are tests of the external behaviour -- feature tests, if you like.
They run the compiled binaries, and make assertions about the return code,
stdout and stderr.
"""
import unittest
from conftest import BaseTest
class TestSafariRS(BaseTest):
def test_urls_all_flag_is_deprecated(self):
result = self.run_safari_rs('urls-all')
self.assertIn('deprecated', result.stderr)
def test_list_tabs_flag_is_not_deprecated(self):
result = self.run_safari_rs('list-tabs')
self.assertNotIn('deprecated', result.stderr)
def test_no_extra_whitespace_on_tidy_url(self):
result = self.run_safari_rs('tidy-url', 'https://github.com/alexwlchan/safari.rs/issues')
assert result.rc == 0
assert result.stderr == ''
assert result.stdout.strip() == result.stdout
def _assert_resolve_tco(self, url, expected):
result = self.run_safari_rs('resolve', url)
assert result.rc == 0
assert result.stderr == ''
assert result.stdout == expected
def test_resolve_single_redirect(self):
self._assert_resolve_tco('https://t.co/2pciHpqpwC', 'https://donmelton.com/2013/06/04/remembering-penny/')
def test_resolve_multiple_redirect(self):
self._assert_resolve_tco('https://t.co/oSJaiNlIP6', 'https://bitly.com/blog/backlinking-strategy/')
def test_resolve_no_redirect(self):
self._assert_resolve_tco('https://example.org/', 'https://example.org/')
if __name__ == '__main__':
unittest.main()
|
e654590b7345b406fdeb6db6ac249da1f60b253c
|
project_euler/solutions/problem_5.py
|
project_euler/solutions/problem_5.py
|
from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise TypeError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
|
from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise ValueError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
|
Use ValueError for wrong input in 5
|
Use ValueError for wrong input in 5
|
Python
|
mit
|
cryvate/project-euler,cryvate/project-euler
|
from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise TypeError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
Use ValueError for wrong input in 5
|
from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise ValueError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
|
<commit_before>from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise TypeError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
<commit_msg>Use ValueError for wrong input in 5<commit_after>
|
from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise ValueError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
|
from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise TypeError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
Use ValueError for wrong input in 5from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise ValueError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
|
<commit_before>from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise TypeError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
<commit_msg>Use ValueError for wrong input in 5<commit_after>from math import gcd
def solve(number: int=20) -> str:
if number <= 0:
raise ValueError
lcd = 1
for i in range(1, number + 1):
lcd = (lcd * i) // gcd(lcd, i)
return str(lcd)
|
153c832f083e8ec801ecb8dbddd2f8e79b735eed
|
utilities.py
|
utilities.py
|
# Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
|
# Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
def write_pvs_to_file(filename, data):
''' Write given pvs to file '''
f = open(filename, 'w')
for element in data:
f.write(element, '\n')
f.close()
|
Add utility function to write pvs to file
|
Add utility function to write pvs to file
|
Python
|
apache-2.0
|
razvanvasile/Work-Mini-Projects,razvanvasile/Work-Mini-Projects,razvanvasile/Work-Mini-Projects
|
# Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
Add utility function to write pvs to file
|
# Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
def write_pvs_to_file(filename, data):
''' Write given pvs to file '''
f = open(filename, 'w')
for element in data:
f.write(element, '\n')
f.close()
|
<commit_before># Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
<commit_msg>Add utility function to write pvs to file<commit_after>
|
# Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
def write_pvs_to_file(filename, data):
''' Write given pvs to file '''
f = open(filename, 'w')
for element in data:
f.write(element, '\n')
f.close()
|
# Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
Add utility function to write pvs to file# Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
def write_pvs_to_file(filename, data):
''' Write given pvs to file '''
f = open(filename, 'w')
for element in data:
f.write(element, '\n')
f.close()
|
<commit_before># Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
<commit_msg>Add utility function to write pvs to file<commit_after># Function to return a list of pvs from a given file
import pkg_resources
pkg_resources.require('aphla')
import aphla as ap
def get_pv_names(mode):
''' Given a certain ring mode as a string, return all available pvs '''
ap.machines.load(mode)
result = set()
elements = ap.getElements('*')
for element in elements:
pvs = element.pv()
if(len(pvs) > 0):
pv_name = pvs[0].split(':')[0]
result.add(pv_name)
return result
def get_pvs_from_file(filepath):
''' Return a list of pvs from a given file '''
with open(filepath) as f:
contents = f.read().splitlines()
return contents
def write_pvs_to_file(filename, data):
''' Write given pvs to file '''
f = open(filename, 'w')
for element in data:
f.write(element, '\n')
f.close()
|
69a94173a48d04bc9e409278574844ebbc43af8b
|
dadd/worker/__init__.py
|
dadd/worker/__init__.py
|
import os
from functools import partial
import click
from flask import Flask
from dadd import server
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if os.environ.get('DEBUG') or (ctx.obj and ctx.obj.get('DEBUG')):
app.debug = True
if ctx.obj:
app.config.update(ctx.obj)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
|
from functools import partial
import click
from flask import Flask
from dadd import server
from dadd.master.utils import update_config
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if ctx.obj:
app.config.update(ctx.obj)
update_config(app)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
|
Allow worker to use APP_SETTINGS_YAML correctly.
|
Allow worker to use APP_SETTINGS_YAML correctly.
|
Python
|
bsd-3-clause
|
ionrock/dadd,ionrock/dadd,ionrock/dadd,ionrock/dadd
|
import os
from functools import partial
import click
from flask import Flask
from dadd import server
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if os.environ.get('DEBUG') or (ctx.obj and ctx.obj.get('DEBUG')):
app.debug = True
if ctx.obj:
app.config.update(ctx.obj)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
Allow worker to use APP_SETTINGS_YAML correctly.
|
from functools import partial
import click
from flask import Flask
from dadd import server
from dadd.master.utils import update_config
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if ctx.obj:
app.config.update(ctx.obj)
update_config(app)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
|
<commit_before>import os
from functools import partial
import click
from flask import Flask
from dadd import server
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if os.environ.get('DEBUG') or (ctx.obj and ctx.obj.get('DEBUG')):
app.debug = True
if ctx.obj:
app.config.update(ctx.obj)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
<commit_msg>Allow worker to use APP_SETTINGS_YAML correctly.<commit_after>
|
from functools import partial
import click
from flask import Flask
from dadd import server
from dadd.master.utils import update_config
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if ctx.obj:
app.config.update(ctx.obj)
update_config(app)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
|
import os
from functools import partial
import click
from flask import Flask
from dadd import server
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if os.environ.get('DEBUG') or (ctx.obj and ctx.obj.get('DEBUG')):
app.debug = True
if ctx.obj:
app.config.update(ctx.obj)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
Allow worker to use APP_SETTINGS_YAML correctly.from functools import partial
import click
from flask import Flask
from dadd import server
from dadd.master.utils import update_config
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if ctx.obj:
app.config.update(ctx.obj)
update_config(app)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
|
<commit_before>import os
from functools import partial
import click
from flask import Flask
from dadd import server
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if os.environ.get('DEBUG') or (ctx.obj and ctx.obj.get('DEBUG')):
app.debug = True
if ctx.obj:
app.config.update(ctx.obj)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
<commit_msg>Allow worker to use APP_SETTINGS_YAML correctly.<commit_after>from functools import partial
import click
from flask import Flask
from dadd import server
from dadd.master.utils import update_config
app = Flask(__name__)
app.config.from_object('dadd.worker.settings')
import dadd.worker.handlers # noqa
@click.command()
@click.pass_context
def run(ctx):
if ctx.obj:
app.config.update(ctx.obj)
update_config(app)
register = partial(dadd.worker.handlers.register,
app.config['HOST'],
app.config['PORT'])
server.monitor('Dadd_Heartbeat', register, 2)
server.mount(app, '/')
server.run(app.config)
|
a499f5fbe63f03a3c404a28e0c1286af74382e09
|
tests/utils.py
|
tests/utils.py
|
import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from .models import Photo
import pickle
def get_image_file():
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = StringIO()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
|
import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from tempfile import NamedTemporaryFile
from .models import Photo
import pickle
def _get_image_file(file_factory):
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = file_factory()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def get_image_file():
return _get_image_file(StringIO)
def get_named_image_file():
return _get_image_file(NamedTemporaryFile)
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
|
Add util for generating named image file
|
Add util for generating named image file
|
Python
|
bsd-3-clause
|
FundedByMe/django-imagekit,tawanda/django-imagekit,tawanda/django-imagekit,FundedByMe/django-imagekit
|
import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from .models import Photo
import pickle
def get_image_file():
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = StringIO()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
Add util for generating named image file
|
import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from tempfile import NamedTemporaryFile
from .models import Photo
import pickle
def _get_image_file(file_factory):
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = file_factory()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def get_image_file():
return _get_image_file(StringIO)
def get_named_image_file():
return _get_image_file(NamedTemporaryFile)
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
|
<commit_before>import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from .models import Photo
import pickle
def get_image_file():
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = StringIO()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
<commit_msg>Add util for generating named image file<commit_after>
|
import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from tempfile import NamedTemporaryFile
from .models import Photo
import pickle
def _get_image_file(file_factory):
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = file_factory()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def get_image_file():
return _get_image_file(StringIO)
def get_named_image_file():
return _get_image_file(NamedTemporaryFile)
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
|
import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from .models import Photo
import pickle
def get_image_file():
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = StringIO()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
Add util for generating named image fileimport os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from tempfile import NamedTemporaryFile
from .models import Photo
import pickle
def _get_image_file(file_factory):
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = file_factory()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def get_image_file():
return _get_image_file(StringIO)
def get_named_image_file():
return _get_image_file(NamedTemporaryFile)
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
|
<commit_before>import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from .models import Photo
import pickle
def get_image_file():
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = StringIO()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
<commit_msg>Add util for generating named image file<commit_after>import os
from django.core.files.base import ContentFile
from imagekit.lib import Image, StringIO
from tempfile import NamedTemporaryFile
from .models import Photo
import pickle
def _get_image_file(file_factory):
"""
See also:
http://en.wikipedia.org/wiki/Lenna
http://sipi.usc.edu/database/database.php?volume=misc&image=12
"""
path = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'assets', 'lenna-800x600-white-border.jpg')
tmp = file_factory()
tmp.write(open(path, 'r+b').read())
tmp.seek(0)
return tmp
def get_image_file():
return _get_image_file(StringIO)
def get_named_image_file():
return _get_image_file(NamedTemporaryFile)
def create_image():
return Image.open(get_image_file())
def create_instance(model_class, image_name):
instance = model_class()
img = get_image_file()
file = ContentFile(img.read())
instance.original_image = file
instance.original_image.save(image_name, file)
instance.save()
img.close()
return instance
def create_photo(name):
return create_instance(Photo, name)
def pickleback(obj):
pickled = StringIO()
pickle.dump(obj, pickled)
pickled.seek(0)
return pickle.load(pickled)
|
87007360cc7ddc0c5d40882bd2f8107db64d1bdf
|
tools/po2js.py
|
tools/po2js.py
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "?";
%s""" % (unicode(os.path.basename(path)), unicode(time.asctime()), u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "%s";
%s""" % (unicode(os.path.basename(path)),
unicode(time.asctime()),
unicode(os.path.splitext(os.path.basename(path))[0]),
u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
|
Add the language code to the translated file
|
Add the language code to the translated file
|
Python
|
apache-2.0
|
operasoftware/dragonfly-build-tools,operasoftware/dragonfly-build-tools
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "?";
%s""" % (unicode(os.path.basename(path)), unicode(time.asctime()), u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
Add the language code to the translated file
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "%s";
%s""" % (unicode(os.path.basename(path)),
unicode(time.asctime()),
unicode(os.path.splitext(os.path.basename(path))[0]),
u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
|
<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "?";
%s""" % (unicode(os.path.basename(path)), unicode(time.asctime()), u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
<commit_msg>Add the language code to the translated file<commit_after>
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "%s";
%s""" % (unicode(os.path.basename(path)),
unicode(time.asctime()),
unicode(os.path.splitext(os.path.basename(path))[0]),
u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
|
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "?";
%s""" % (unicode(os.path.basename(path)), unicode(time.asctime()), u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
Add the language code to the translated file#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "%s";
%s""" % (unicode(os.path.basename(path)),
unicode(time.asctime()),
unicode(os.path.splitext(os.path.basename(path))[0]),
u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
|
<commit_before>#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "?";
%s""" % (unicode(os.path.basename(path)), unicode(time.asctime()), u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
<commit_msg>Add the language code to the translated file<commit_after>#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys
import os.path
import codecs
import dfstrings
import time
def make_js_from_po(path):
strings = []
for po in [p for p in dfstrings.get_po_strings(path) if "scope" in p and "dragonfly" in p["scope"] ]:
strings.append(u"""ui_strings.%s="%s";""" % (po["jsname"], po["msgstr"]))
return """/* Generated from %s at %s */
window.ui_strings || ( window.ui_strings = {} )
window.ui_strings.lang_code = "%s";
%s""" % (unicode(os.path.basename(path)),
unicode(time.asctime()),
unicode(os.path.splitext(os.path.basename(path))[0]),
u"\n".join(strings))
def main():
if len(sys.argv)==1:
print "Usage: po2js.py infile [outfile]. If no outfile, write to stdout"
return(1)
else:
infile = sys.argv[1]
if len(sys.argv)==3:
outfile = codecs.open(sys.argv[2], "w", encoding="utf_8_sig")
else:
outfile = sys.stdout
data = make_js_from_po(infile)
outfile.write(data)
return 0
if __name__ == "__main__":
sys.exit(main())
|
8004590503914d9674a0b17f412c8d1836f5e1a1
|
testScript.py
|
testScript.py
|
from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821')
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
|
from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821') ## author with more than 25 docs
##myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:55934026500') ## author with less than 25 docs
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
|
Add second author for testing purposes
|
Add second author for testing purposes
|
Python
|
bsd-3-clause
|
ElsevierDev/elsapy
|
from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821')
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
Add second author for testing purposes
|
from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821') ## author with more than 25 docs
##myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:55934026500') ## author with less than 25 docs
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
|
<commit_before>from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821')
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
<commit_msg>Add second author for testing purposes<commit_after>
|
from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821') ## author with more than 25 docs
##myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:55934026500') ## author with less than 25 docs
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
|
from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821')
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
Add second author for testing purposesfrom elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821') ## author with more than 25 docs
##myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:55934026500') ## author with less than 25 docs
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
|
<commit_before>from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821')
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
<commit_msg>Add second author for testing purposes<commit_after>from elsapy import *
conFile = open("config.json")
config = json.load(conFile)
myCl = elsClient(config['apikey'])
myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:7004367821') ## author with more than 25 docs
##myAuth = elsAuthor('http://api.elsevier.com/content/author/AUTHOR_ID:55934026500') ## author with less than 25 docs
myAuth.read(myCl)
print ("myAuth.fullName: ", myAuth.fullName)
myAff = elsAffil('http://api.elsevier.com/content/affiliation/AFFILIATION_ID:60016849')
myAff.read(myCl)
print ("myAff.name: ", myAff.name)
myDoc = elsDoc('http://api.elsevier.com/content/abstract/SCOPUS_ID:84872135457')
myDoc.read(myCl)
print ("myDoc.title: ", myDoc.title)
myAuth.readDocs(myCl)
print ("myAuth.docList: ")
i = 0
for doc in myAuth.docList:
i += 1
print (i, ' - ', doc['dc:title'])
|
5b64a272d0830c3a85fe540a82d6ff8b62bd0ea8
|
livinglots_organize/templatetags/organize_tags.py
|
livinglots_organize/templatetags/organize_tags.py
|
"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
|
"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from django.contrib.contenttypes.models import ContentType
from classytags.arguments import Argument, KeywordArgument
from classytags.core import Options
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
options = Options(
'for',
Argument('target', required=True, resolve=True),
KeywordArgument('public', default=False, required=False),
)
def get_context(self, context, target, public=False):
context.update({
self.get_model_plural_name(): self.get_objects(target, public=public),
})
return context
def get_objects(self, target, public=False):
return self.model.objects.filter(
content_type=ContentType.objects.get_for_model(target),
object_id=target.pk,
post_publicly=public,
)
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
|
Add `public` keyword to render_organizer_list
|
Add `public` keyword to render_organizer_list
|
Python
|
agpl-3.0
|
596acres/django-livinglots-organize,596acres/django-livinglots-organize
|
"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
Add `public` keyword to render_organizer_list
|
"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from django.contrib.contenttypes.models import ContentType
from classytags.arguments import Argument, KeywordArgument
from classytags.core import Options
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
options = Options(
'for',
Argument('target', required=True, resolve=True),
KeywordArgument('public', default=False, required=False),
)
def get_context(self, context, target, public=False):
context.update({
self.get_model_plural_name(): self.get_objects(target, public=public),
})
return context
def get_objects(self, target, public=False):
return self.model.objects.filter(
content_type=ContentType.objects.get_for_model(target),
object_id=target.pk,
post_publicly=public,
)
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
|
<commit_before>"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
<commit_msg>Add `public` keyword to render_organizer_list<commit_after>
|
"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from django.contrib.contenttypes.models import ContentType
from classytags.arguments import Argument, KeywordArgument
from classytags.core import Options
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
options = Options(
'for',
Argument('target', required=True, resolve=True),
KeywordArgument('public', default=False, required=False),
)
def get_context(self, context, target, public=False):
context.update({
self.get_model_plural_name(): self.get_objects(target, public=public),
})
return context
def get_objects(self, target, public=False):
return self.model.objects.filter(
content_type=ContentType.objects.get_for_model(target),
object_id=target.pk,
post_publicly=public,
)
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
|
"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
Add `public` keyword to render_organizer_list"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from django.contrib.contenttypes.models import ContentType
from classytags.arguments import Argument, KeywordArgument
from classytags.core import Options
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
options = Options(
'for',
Argument('target', required=True, resolve=True),
KeywordArgument('public', default=False, required=False),
)
def get_context(self, context, target, public=False):
context.update({
self.get_model_plural_name(): self.get_objects(target, public=public),
})
return context
def get_objects(self, target, public=False):
return self.model.objects.filter(
content_type=ContentType.objects.get_for_model(target),
object_id=target.pk,
post_publicly=public,
)
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
|
<commit_before>"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
<commit_msg>Add `public` keyword to render_organizer_list<commit_after>"""
Template tags for the organize app, loosely based on django.contrib.comments.
"""
from django import template
from django.contrib.contenttypes.models import ContentType
from classytags.arguments import Argument, KeywordArgument
from classytags.core import Options
from livinglots import get_organizer_model
from livinglots_generictags.tags import (GetGenericRelationList,
RenderGenericRelationList,
GetGenericRelationCount)
register = template.Library()
class RenderOrganizerList(RenderGenericRelationList):
model = get_organizer_model()
template_dir_prefix = 'livinglots'
options = Options(
'for',
Argument('target', required=True, resolve=True),
KeywordArgument('public', default=False, required=False),
)
def get_context(self, context, target, public=False):
context.update({
self.get_model_plural_name(): self.get_objects(target, public=public),
})
return context
def get_objects(self, target, public=False):
return self.model.objects.filter(
content_type=ContentType.objects.get_for_model(target),
object_id=target.pk,
post_publicly=public,
)
register.tag(RenderOrganizerList)
class GetOrganizerList(GetGenericRelationList):
model = get_organizer_model()
register.tag(GetOrganizerList)
class GetOrganizerCount(GetGenericRelationCount):
model = get_organizer_model()
register.tag(GetOrganizerCount)
|
1105dfb75bf373b38e2f12579843af54f7a78c6f
|
DataModelAdapter.py
|
DataModelAdapter.py
|
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
|
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def child(self, row) :
children_list = [c for c in self._children]
return children_list[row]
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
|
Add child(); TODO: test this
|
Add child(); TODO: test this
|
Python
|
apache-2.0
|
mattdeckard/wherewithal
|
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
Add child(); TODO: test this
|
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def child(self, row) :
children_list = [c for c in self._children]
return children_list[row]
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
|
<commit_before>
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
<commit_msg>Add child(); TODO: test this<commit_after>
|
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def child(self, row) :
children_list = [c for c in self._children]
return children_list[row]
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
|
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
Add child(); TODO: test this
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def child(self, row) :
children_list = [c for c in self._children]
return children_list[row]
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
|
<commit_before>
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
<commit_msg>Add child(); TODO: test this<commit_after>
class DataModelAdapter(object) :
def __init__(self, data) :
self._data = data
self._children = set()
self._parent = None
pass
def numChildren(self) :
return len(self._children)
def hasData(self) :
return self._data is not None
def getData(self, key) :
if key in self._data :
return self._data[key]
return None
def addChild(self, child) :
child.setParent(self)
self._children.add(child)
def child(self, row) :
children_list = [c for c in self._children]
return children_list[row]
def setParent(self, parent) :
self._parent = parent
def parent(self) :
return self._parent
|
b53a6fb45934856fcf1aca419b4022241fc7fcbc
|
tests/t_all.py
|
tests/t_all.py
|
#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case != 't_expire' and case != 't_multi':
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
|
#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
# $ python t_all.py MultiTestCase
# $ python t_all.py ScriptTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case not in ('t_expire', 't_multi', 't_script'):
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
def MultiTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_multi')
def ScriptTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_script')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
|
Exclude the play script test case from the default test suite.
|
Exclude the play script test case from the default test suite.
|
Python
|
bsd-3-clause
|
sapo/python-kyototycoon,sapo/python-kyototycoon-ng
|
#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case != 't_expire' and case != 't_multi':
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
Exclude the play script test case from the default test suite.
|
#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
# $ python t_all.py MultiTestCase
# $ python t_all.py ScriptTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case not in ('t_expire', 't_multi', 't_script'):
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
def MultiTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_multi')
def ScriptTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_script')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
|
<commit_before>#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case != 't_expire' and case != 't_multi':
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
<commit_msg>Exclude the play script test case from the default test suite.<commit_after>
|
#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
# $ python t_all.py MultiTestCase
# $ python t_all.py ScriptTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case not in ('t_expire', 't_multi', 't_script'):
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
def MultiTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_multi')
def ScriptTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_script')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
|
#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case != 't_expire' and case != 't_multi':
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
Exclude the play script test case from the default test suite.#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
# $ python t_all.py MultiTestCase
# $ python t_all.py ScriptTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case not in ('t_expire', 't_multi', 't_script'):
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
def MultiTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_multi')
def ScriptTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_script')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
|
<commit_before>#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case != 't_expire' and case != 't_multi':
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
<commit_msg>Exclude the play script test case from the default test suite.<commit_after>#!/usr/bin/env python
#
# Copyright 2011, Toru Maesaka
#
# Redistribution and use of this source code is licensed under
# the BSD license. See COPYING file for license description.
#
# USAGE:
# $ python t_all.py
# $ python t_all.py ExpireTestCase
# $ python t_all.py MultiTestCase
# $ python t_all.py ScriptTestCase
import os
import re
import unittest
_TEST_MODULE_PATTERN = re.compile(r'^(t_.+)\.py$')
def _run_all_tests():
module_names = []
loader = unittest.TestLoader()
test_path = os.path.join(os.path.split(__file__)[0], '.')
for filename in os.listdir(test_path):
match = _TEST_MODULE_PATTERN.search(filename)
if match:
case = match.group(1)
if case not in ('t_expire', 't_multi', 't_script'):
module_names.append(case)
return loader.loadTestsFromNames(module_names)
def ExpireTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_expire')
def MultiTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_multi')
def ScriptTestCase():
loader = unittest.TestLoader()
return loader.loadTestsFromName('t_script')
if __name__ == '__main__':
unittest.main(defaultTest='_run_all_tests')
|
be73d527c87ce94e4e4d4c80c6ef797aad803f50
|
opps/__init__.py
|
opps/__init__.py
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
trans_app_label = _('Opps')
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
|
Remove trans app label on opps init
|
Remove trans app label on opps init
|
Python
|
mit
|
jeanmask/opps,jeanmask/opps,opps/opps,jeanmask/opps,YACOWS/opps,YACOWS/opps,opps/opps,williamroot/opps,williamroot/opps,YACOWS/opps,opps/opps,YACOWS/opps,williamroot/opps,opps/opps,jeanmask/opps,williamroot/opps
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
trans_app_label = _('Opps')
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
Remove trans app label on opps init
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
|
<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
trans_app_label = _('Opps')
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
<commit_msg>Remove trans app label on opps init<commit_after>
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
|
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
trans_app_label = _('Opps')
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
Remove trans app label on opps init#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
|
<commit_before>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
trans_app_label = _('Opps')
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
<commit_msg>Remove trans app label on opps init<commit_after>#!/usr/bin/env python
# -*- coding: utf-8 -*-
import pkg_resources
pkg_resources.declare_namespace(__name__)
VERSION = (0, 1, 4)
__version__ = ".".join(map(str, VERSION))
__status__ = "Development"
__description__ = u"Opps CMS websites magazines and high-traffic"
__author__ = u"Thiago Avelino"
__credits__ = []
__email__ = u"[email protected]"
__license__ = u"MIT License"
__copyright__ = u"Copyright 2013, YACOWS"
|
4e8c84bf36250d7e61b585fc5db545206cab9730
|
perfkitbenchmarker/scripts/spark_table.py
|
perfkitbenchmarker/scripts/spark_table.py
|
# Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('drop table if exists ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
if __name__ == '__main__':
main()
|
# Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
from pyspark.sql.utils import AnalysisException
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('DROP TABLE IF EXISTS ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
try:
# This loads the partitions under the table if table is partitioned.
spark.sql('MSCK REPAIR TABLE ' + table)
except AnalysisException:
# The table was not partitioned, which was presumably expected
pass
if __name__ == '__main__':
main()
|
Support creating Hive tables with partitioned data.
|
Support creating Hive tables with partitioned data.
PiperOrigin-RevId: 335539022
|
Python
|
apache-2.0
|
GoogleCloudPlatform/PerfKitBenchmarker,GoogleCloudPlatform/PerfKitBenchmarker,GoogleCloudPlatform/PerfKitBenchmarker,GoogleCloudPlatform/PerfKitBenchmarker
|
# Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('drop table if exists ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
if __name__ == '__main__':
main()
Support creating Hive tables with partitioned data.
PiperOrigin-RevId: 335539022
|
# Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
from pyspark.sql.utils import AnalysisException
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('DROP TABLE IF EXISTS ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
try:
# This loads the partitions under the table if table is partitioned.
spark.sql('MSCK REPAIR TABLE ' + table)
except AnalysisException:
# The table was not partitioned, which was presumably expected
pass
if __name__ == '__main__':
main()
|
<commit_before># Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('drop table if exists ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
if __name__ == '__main__':
main()
<commit_msg>Support creating Hive tables with partitioned data.
PiperOrigin-RevId: 335539022<commit_after>
|
# Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
from pyspark.sql.utils import AnalysisException
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('DROP TABLE IF EXISTS ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
try:
# This loads the partitions under the table if table is partitioned.
spark.sql('MSCK REPAIR TABLE ' + table)
except AnalysisException:
# The table was not partitioned, which was presumably expected
pass
if __name__ == '__main__':
main()
|
# Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('drop table if exists ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
if __name__ == '__main__':
main()
Support creating Hive tables with partitioned data.
PiperOrigin-RevId: 335539022# Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
from pyspark.sql.utils import AnalysisException
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('DROP TABLE IF EXISTS ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
try:
# This loads the partitions under the table if table is partitioned.
spark.sql('MSCK REPAIR TABLE ' + table)
except AnalysisException:
# The table was not partitioned, which was presumably expected
pass
if __name__ == '__main__':
main()
|
<commit_before># Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('drop table if exists ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
if __name__ == '__main__':
main()
<commit_msg>Support creating Hive tables with partitioned data.
PiperOrigin-RevId: 335539022<commit_after># Lint as: python2, python3
"""A PySpark driver that creates Spark tables for Spark SQL benchmark.
It takes an HCFS directory and a list of the names of the subdirectories of that
root directory. The subdirectories each hold Parquet data and are to be
converted into a table of the same name. The subdirectories are explicitly
providing because listing HCFS directories in PySpark is ugly.
sys.argv[1]: The root HCFS directory
sys.argv[2]: A comma separated list of the subdirectories/table names
"""
from __future__ import absolute_import
from __future__ import division
from __future__ import print_function
import argparse
import logging
import os
from pyspark.sql import SparkSession
from pyspark.sql.utils import AnalysisException
def main():
parser = argparse.ArgumentParser()
parser.add_argument('root_dir')
parser.add_argument('tables', type=lambda csv: csv.split(','))
args = parser.parse_args()
spark = (SparkSession.builder
.appName('Setup Spark tables')
.enableHiveSupport()
.getOrCreate())
for table in args.tables:
logging.info('Creating table %s', table)
table_dir = os.path.join(args.root_dir, table)
# clean up previous table
spark.sql('DROP TABLE IF EXISTS ' + table)
# register new table
spark.catalog.createTable(table, table_dir, source='parquet')
try:
# This loads the partitions under the table if table is partitioned.
spark.sql('MSCK REPAIR TABLE ' + table)
except AnalysisException:
# The table was not partitioned, which was presumably expected
pass
if __name__ == '__main__':
main()
|
74e75cba3c923bc4aea9a7f1c4f387d29227f003
|
pyramid_jsonapi/version.py
|
pyramid_jsonapi/version.py
|
#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.post'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
|
#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.dev'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
|
Make inbetween tag releases 'dev', not 'post'.
|
Make inbetween tag releases 'dev', not 'post'.
|
Python
|
agpl-3.0
|
colinhiggs/pyramid-jsonapi,colinhiggs/pyramid-jsonapi
|
#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.post'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
Make inbetween tag releases 'dev', not 'post'.
|
#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.dev'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
|
<commit_before>#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.post'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
<commit_msg>Make inbetween tag releases 'dev', not 'post'.<commit_after>
|
#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.dev'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
|
#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.post'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
Make inbetween tag releases 'dev', not 'post'.#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.dev'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
|
<commit_before>#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.post'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
<commit_msg>Make inbetween tag releases 'dev', not 'post'.<commit_after>#!/usr/bin/env python
# Source: https://github.com/Changaco/version.py
from os.path import dirname, isdir, join
import re
from subprocess import CalledProcessError, check_output
PREFIX = ''
tag_re = re.compile(r'\btag: %s([0-9][^,]*)\b' % PREFIX)
version_re = re.compile('^Version: (.+)$', re.M)
def get_version():
# Return the version if it has been injected into the file by git-archive
version = tag_re.search('$Format:%D$')
if version:
return version.group(1)
d = dirname(__file__)
if isdir(join(d, '../.git')):
# Get the version using "git describe".
cmd = 'git describe --tags --match %s[0-9]* --dirty' % PREFIX
try:
version = check_output(cmd.split()).decode().strip()[len(PREFIX):]
except CalledProcessError:
raise RuntimeError('Unable to get version number from git tags')
# PEP 440 compatibility
if '-' in version:
version = '.dev'.join(version.split('-')[:2])
else:
# Extract the version from the PKG-INFO file.
with open(join(d, '../PKG-INFO')) as f:
version = version_re.search(f.read()).group(1)
return version
if __name__ == '__main__':
print(get_version())
|
35f45d3fcee5a1fe9d6d5ce71b708d0bc68db3fc
|
python/matasano/set1/c7.py
|
python/matasano/set1/c7.py
|
from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64_to_bytes(chal_file.read()).encode('latin-1')
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
|
from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64.b64decode(chal_file.read())
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
|
Switch to using base64 builtin decoder for simplicity.
|
Switch to using base64 builtin decoder for simplicity.
|
Python
|
mit
|
TheLunchtimeAttack/matasano-challenges,TheLunchtimeAttack/matasano-challenges
|
from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64_to_bytes(chal_file.read()).encode('latin-1')
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
Switch to using base64 builtin decoder for simplicity.
|
from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64.b64decode(chal_file.read())
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
|
<commit_before>from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64_to_bytes(chal_file.read()).encode('latin-1')
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
<commit_msg>Switch to using base64 builtin decoder for simplicity.<commit_after>
|
from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64.b64decode(chal_file.read())
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
|
from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64_to_bytes(chal_file.read()).encode('latin-1')
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
Switch to using base64 builtin decoder for simplicity.from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64.b64decode(chal_file.read())
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
|
<commit_before>from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64_to_bytes(chal_file.read()).encode('latin-1')
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
<commit_msg>Switch to using base64 builtin decoder for simplicity.<commit_after>from matasano.util.converters import base64_to_bytes
from Crypto.Cipher import AES
import base64
if __name__ == "__main__":
chal_file = open("matasano/data/c7.txt", 'r');
key = "YELLOW SUBMARINE"
# Instantiate the cipher
cipher = AES.new(key, AES.MODE_ECB)
# Covert from base64 to bytes and encode
ct = base64.b64decode(chal_file.read())
# Perform the decryption
pt = cipher.decrypt(ct)
print(pt.decode())
|
31ee90e07287ea9b7da940293564f323eedf55bb
|
quark/mdk_runtime_files.py
|
quark/mdk_runtime_files.py
|
import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents)
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "rb") as f:
return f.read()
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
|
import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents.encode("utf-8"))
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "r") as f:
return f.read().decode("utf-8")
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
|
Fix mdk runtime to encode/decode file contents
|
Fix mdk runtime to encode/decode file contents
|
Python
|
apache-2.0
|
datawire/mdk,datawire/mdk,datawire/mdk,datawire/mdk
|
import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents)
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "rb") as f:
return f.read()
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
Fix mdk runtime to encode/decode file contents
|
import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents.encode("utf-8"))
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "r") as f:
return f.read().decode("utf-8")
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
|
<commit_before>import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents)
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "rb") as f:
return f.read()
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
<commit_msg>Fix mdk runtime to encode/decode file contents<commit_after>
|
import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents.encode("utf-8"))
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "r") as f:
return f.read().decode("utf-8")
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
|
import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents)
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "rb") as f:
return f.read()
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
Fix mdk runtime to encode/decode file contentsimport os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents.encode("utf-8"))
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "r") as f:
return f.read().decode("utf-8")
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
|
<commit_before>import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents)
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "rb") as f:
return f.read()
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
<commit_msg>Fix mdk runtime to encode/decode file contents<commit_after>import os
import tempfile
"""
TODO: This is all semi-broken since in Python quark.String is not Unicode
all the time.
"""
__all__ = ["_mdk_mktempdir", "_mdk_writefile", "_mdk_deletefile",
"_mdk_file_contents", "_mdk_readfile"]
def _mdk_mktempdir():
"""Create temporary directory."""
return tempfile.mkdtemp()
def _mdk_writefile(path, contents):
"""Write a file to disk."""
with open(path, "wb") as f:
f.write(contents.encode("utf-8"))
def _mdk_readfile(path):
"""Read a file's contents."""
with open(path, "r") as f:
return f.read().decode("utf-8")
def _mdk_deletefile(path):
"""Delete a file."""
os.remove(path)
def _mdk_file_contents(path):
"""List contents of directory, or just the file if it's a file."""
if os.path.isdir(path):
return [os.path.join(path, name) for name in os.listdir(path)]
else:
return [path]
|
c83aa290e4c38238d39260f002722d8c9663093a
|
main/model/pay.py
|
main/model/pay.py
|
# coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateTimeProperty(auto_now_add=True)
date_paid = ndb.DateTimeProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
|
# coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateProperty(auto_now_add=True)
date_paid = ndb.DateProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
|
Change datetime property to date
|
Change datetime property to date
|
Python
|
mit
|
georgekis/salary,georgekis/salary,georgekis/salary
|
# coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateTimeProperty(auto_now_add=True)
date_paid = ndb.DateTimeProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
Change datetime property to date
|
# coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateProperty(auto_now_add=True)
date_paid = ndb.DateProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
|
<commit_before># coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateTimeProperty(auto_now_add=True)
date_paid = ndb.DateTimeProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
<commit_msg>Change datetime property to date<commit_after>
|
# coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateProperty(auto_now_add=True)
date_paid = ndb.DateProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
|
# coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateTimeProperty(auto_now_add=True)
date_paid = ndb.DateTimeProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
Change datetime property to date# coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateProperty(auto_now_add=True)
date_paid = ndb.DateProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
|
<commit_before># coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateTimeProperty(auto_now_add=True)
date_paid = ndb.DateTimeProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
<commit_msg>Change datetime property to date<commit_after># coding: utf-8
from __future__ import absolute_import
from google.appengine.ext import ndb
from api import fields
import config
import model
import util
class Pay(model.Base):
name = ndb.StringProperty(default='')
date_for = ndb.DateProperty(auto_now_add=True)
date_paid = ndb.DateProperty(auto_now_add=True)
code = ndb.StringProperty(default='')
amount = ndb.FloatProperty(default=0.0)
@ndb.ComputedProperty
def amount_format(self):
return u'%s %0.2f' % (config.CONFIG_DB.currency, self.amount)
@ndb.ComputedProperty
def is_positive(self):
return self.amount >= 0
@classmethod
def get_dbs(cls, is_positive=None, **kwargs):
return super(Pay, cls).get_dbs(
is_positive=is_positive or util.param('is_positive', bool),
**kwargs
)
PAY_FIELDS = {
'amount': fields.Float,
'amount_format': fields.String,
'code': fields.String,
'date_for': fields.DateTimeField,
'date_paid': fields.DateTimeField,
'is_positive': fields.Boolean,
'name': fields.String,
}
PAY_FIELDS.update(model.BASE_FIELDS)
|
0da81b53b521c22368899211dc851d6147e1a30d
|
common_components/static_renderers.py
|
common_components/static_renderers.py
|
from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
def __call__(self):
return '<link rel="stylesheet" href="{}" />'.format(self.url)
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
def __call__(self):
return '<script src="{}"></script>'.format(self.url)
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
|
from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
|
Revert "fixed rendering of Sass and Coffee"
|
Revert "fixed rendering of Sass and Coffee"
This reverts commit b21834c9d439603f666d17aea338934bae063ef4.
|
Python
|
mpl-2.0
|
Zer0-/common_components
|
from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
def __call__(self):
return '<link rel="stylesheet" href="{}" />'.format(self.url)
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
def __call__(self):
return '<script src="{}"></script>'.format(self.url)
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
Revert "fixed rendering of Sass and Coffee"
This reverts commit b21834c9d439603f666d17aea338934bae063ef4.
|
from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
|
<commit_before>from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
def __call__(self):
return '<link rel="stylesheet" href="{}" />'.format(self.url)
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
def __call__(self):
return '<script src="{}"></script>'.format(self.url)
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
<commit_msg>Revert "fixed rendering of Sass and Coffee"
This reverts commit b21834c9d439603f666d17aea338934bae063ef4.<commit_after>
|
from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
|
from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
def __call__(self):
return '<link rel="stylesheet" href="{}" />'.format(self.url)
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
def __call__(self):
return '<script src="{}"></script>'.format(self.url)
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
Revert "fixed rendering of Sass and Coffee"
This reverts commit b21834c9d439603f666d17aea338934bae063ef4.from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
|
<commit_before>from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
def __call__(self):
return '<link rel="stylesheet" href="{}" />'.format(self.url)
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
def __call__(self):
return '<script src="{}"></script>'.format(self.url)
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
<commit_msg>Revert "fixed rendering of Sass and Coffee"
This reverts commit b21834c9d439603f666d17aea338934bae063ef4.<commit_after>from os.path import join, splitext, basename
from bricks.staticfiles import StaticCss, StaticJs, StaticFile
class _BuiltStatic(StaticFile):
has_build_stage = True
def __init__(self, *args):
StaticFile.__init__(self, *args)
self.url = self.url.rsplit('.', 1)[0] + '.' + self.target_type
class Sass(_BuiltStatic):
relpath = 'scss'
target_type = 'css'
class Coffee(_BuiltStatic):
relpath = 'coffee'
target_type = 'js'
class StaticLib(StaticFile):
"""A static asset or a directory with static assets that's needed
to build other static assets but is not directly used by the page."""
has_build_stage = True
def __call__(self):
return ''
class SassLib(StaticLib):
relpath = 'scss'
|
61de7c1827867cea3385c5db3862e5e68caa98fd
|
Puli/src/octopus/dispatcher/rules/graphview.py
|
Puli/src/octopus/dispatcher/rules/graphview.py
|
from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
|
from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
def __repr__(self):
return "GraphViewBuilder( root=%r, dispatchTree=%r )" % (self.root, self.dispatchTree )
|
Add a representation of GraphView object
|
Add a representation of GraphView object
|
Python
|
bsd-3-clause
|
mikrosimage/OpenRenderManagement,mikrosimage/OpenRenderManagement,smaragden/OpenRenderManagement,smaragden/OpenRenderManagement,smaragden/OpenRenderManagement,mikrosimage/OpenRenderManagement
|
from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
Add a representation of GraphView object
|
from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
def __repr__(self):
return "GraphViewBuilder( root=%r, dispatchTree=%r )" % (self.root, self.dispatchTree )
|
<commit_before>from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
<commit_msg>Add a representation of GraphView object<commit_after>
|
from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
def __repr__(self):
return "GraphViewBuilder( root=%r, dispatchTree=%r )" % (self.root, self.dispatchTree )
|
from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
Add a representation of GraphView objectfrom octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
def __repr__(self):
return "GraphViewBuilder( root=%r, dispatchTree=%r )" % (self.root, self.dispatchTree )
|
<commit_before>from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
<commit_msg>Add a representation of GraphView object<commit_after>from octopus.dispatcher.model import TaskNode, FolderNode, TaskGroup
from octopus.dispatcher import rules
import logging
logger = logging.getLogger("dispatcher")
class RuleError(rules.RuleError):
'''Base class for GraphViewBuilder related exceptions.'''
pass
class TaskNodeHasNoChildrenError(RuleError):
'''Raised when a GraphViewBuilder is requested to add a child node
to a FolderNode.
'''
class GraphViewBuilder(object):
def __init__(self, dispatchTree, root):
self.dispatchTree = dispatchTree
self.root = root
def apply(self, task):
id = None
name = task.name
parent = task.parent.nodes['graph_rule'] if task.parent else self.root
user = task.user
priority = task.priority
dispatchKey = task.dispatchKey
maxRN = task.maxRN
if isinstance(task, TaskGroup):
strategy = task.strategy
node = FolderNode(id, name, parent, user, priority, dispatchKey, maxRN,
strategy, taskGroup=task)
else:
node = TaskNode(None, name, parent, user, priority, dispatchKey, maxRN, task)
task.nodes['graph_rule'] = node
return [node]
def processDependencies(self, dependencies):
for task, taskdeps in dependencies.items():
node = task.nodes['graph_rule']
for deptask, statuslist in taskdeps.items():
depnode = deptask.nodes['graph_rule']
node.addDependency(depnode, statuslist)
def __repr__(self):
return "GraphViewBuilder( root=%r, dispatchTree=%r )" % (self.root, self.dispatchTree )
|
f32ab8ebd509df7e815fb96189974e7db44af3e3
|
plugins/owner.py
|
plugins/owner.py
|
import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
class Owner(Plugin):
"""
Owner-only commands.
"""
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
|
import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
def is_owner(self, ctx: Context):
return ctx.author.id == 141545699442425856 or ctx.message.author.id == ctx.bot.application_info.owner.id
class Owner(Plugin):
"""
Owner-only commands.
"""
plugin_check = is_owner
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
@commands.command(name="load", invokation_checks=[is_owner])
async def _load(self, ctx: Context, *, import_name: str):
"""
Loads a plugin.
"""
await self.bot.load_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Loaded.")
@commands.command(name="unload", invokation_checks=[is_owner])
async def _unload(self, ctx: Context, *, import_name: str):
"""
Unloads a plugin.
"""
await self.bot.unload_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Unloaded.")
|
Add load and unload commands.
|
Add load and unload commands.
|
Python
|
mit
|
SunDwarf/curiosity
|
import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
class Owner(Plugin):
"""
Owner-only commands.
"""
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
Add load and unload commands.
|
import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
def is_owner(self, ctx: Context):
return ctx.author.id == 141545699442425856 or ctx.message.author.id == ctx.bot.application_info.owner.id
class Owner(Plugin):
"""
Owner-only commands.
"""
plugin_check = is_owner
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
@commands.command(name="load", invokation_checks=[is_owner])
async def _load(self, ctx: Context, *, import_name: str):
"""
Loads a plugin.
"""
await self.bot.load_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Loaded.")
@commands.command(name="unload", invokation_checks=[is_owner])
async def _unload(self, ctx: Context, *, import_name: str):
"""
Unloads a plugin.
"""
await self.bot.unload_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Unloaded.")
|
<commit_before>import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
class Owner(Plugin):
"""
Owner-only commands.
"""
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
<commit_msg>Add load and unload commands.<commit_after>
|
import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
def is_owner(self, ctx: Context):
return ctx.author.id == 141545699442425856 or ctx.message.author.id == ctx.bot.application_info.owner.id
class Owner(Plugin):
"""
Owner-only commands.
"""
plugin_check = is_owner
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
@commands.command(name="load", invokation_checks=[is_owner])
async def _load(self, ctx: Context, *, import_name: str):
"""
Loads a plugin.
"""
await self.bot.load_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Loaded.")
@commands.command(name="unload", invokation_checks=[is_owner])
async def _unload(self, ctx: Context, *, import_name: str):
"""
Unloads a plugin.
"""
await self.bot.unload_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Unloaded.")
|
import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
class Owner(Plugin):
"""
Owner-only commands.
"""
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
Add load and unload commands.import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
def is_owner(self, ctx: Context):
return ctx.author.id == 141545699442425856 or ctx.message.author.id == ctx.bot.application_info.owner.id
class Owner(Plugin):
"""
Owner-only commands.
"""
plugin_check = is_owner
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
@commands.command(name="load", invokation_checks=[is_owner])
async def _load(self, ctx: Context, *, import_name: str):
"""
Loads a plugin.
"""
await self.bot.load_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Loaded.")
@commands.command(name="unload", invokation_checks=[is_owner])
async def _unload(self, ctx: Context, *, import_name: str):
"""
Unloads a plugin.
"""
await self.bot.unload_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Unloaded.")
|
<commit_before>import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
class Owner(Plugin):
"""
Owner-only commands.
"""
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
<commit_msg>Add load and unload commands.<commit_after>import inspect
import traceback
from curious import commands
from curious.commands.context import Context
from curious.commands.plugin import Plugin
def is_owner(self, ctx: Context):
return ctx.author.id == 141545699442425856 or ctx.message.author.id == ctx.bot.application_info.owner.id
class Owner(Plugin):
"""
Owner-only commands.
"""
plugin_check = is_owner
@commands.command(name="eval")
async def _eval(self, ctx: Context, *, eval_str: str):
msg = await ctx.channel.send("Evaluating...")
try:
result = eval(eval_str)
if inspect.isawaitable(result):
result = await result
result = str(result)
except Exception as e:
tb = ''.join(traceback.format_exc())
result = tb
fmtted = "```py\n{}\n```".format(result)
await msg.edit(fmtted)
@commands.command(name="load", invokation_checks=[is_owner])
async def _load(self, ctx: Context, *, import_name: str):
"""
Loads a plugin.
"""
await self.bot.load_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Loaded.")
@commands.command(name="unload", invokation_checks=[is_owner])
async def _unload(self, ctx: Context, *, import_name: str):
"""
Unloads a plugin.
"""
await self.bot.unload_plugins_from(import_name)
await ctx.message.channel.send(":heavy_check_mark: Unloaded.")
|
f5b1975aebf50af78d41b8f192dabc128ad78b2a
|
sc2reader/engine/plugins/__init__.py
|
sc2reader/engine/plugins/__init__.py
|
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
>>>>>>> GameHeart Plugin
|
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
|
Fix a small rebase error, my bad.
|
Fix a small rebase error, my bad.
|
Python
|
mit
|
StoicLoofah/sc2reader,ggtracker/sc2reader,StoicLoofah/sc2reader,ggtracker/sc2reader
|
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
>>>>>>> GameHeart Plugin
Fix a small rebase error, my bad.
|
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
|
<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
>>>>>>> GameHeart Plugin
<commit_msg>Fix a small rebase error, my bad.<commit_after>
|
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
|
# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
>>>>>>> GameHeart Plugin
Fix a small rebase error, my bad.# -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
|
<commit_before># -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
>>>>>>> GameHeart Plugin
<commit_msg>Fix a small rebase error, my bad.<commit_after># -*- coding: utf-8 -*-
from __future__ import absolute_import, print_function, unicode_literals, division
from sc2reader.engine.plugins.apm import APMTracker
from sc2reader.engine.plugins.selection import SelectionTracker
from sc2reader.engine.plugins.context import ContextLoader
from sc2reader.engine.plugins.supply import SupplyTracker
from sc2reader.engine.plugins.creeptracker import CreepTracker
from sc2reader.engine.plugins.gameheart import GameHeartNormalizer
|
dfc46790bf8cf20f1901f99c7a97530e15fbf97c
|
api/search/urls.py
|
api/search/urls.py
|
from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institution/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
|
from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institutions/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
|
Update name of institution search URL route
|
Update name of institution search URL route
|
Python
|
apache-2.0
|
crcresearch/osf.io,erinspace/osf.io,felliott/osf.io,binoculars/osf.io,Johnetordoff/osf.io,sloria/osf.io,Johnetordoff/osf.io,aaxelb/osf.io,saradbowman/osf.io,caneruguz/osf.io,mattclark/osf.io,erinspace/osf.io,hmoco/osf.io,Nesiehr/osf.io,chrisseto/osf.io,cslzchen/osf.io,brianjgeiger/osf.io,mattclark/osf.io,saradbowman/osf.io,HalcyonChimera/osf.io,mfraezz/osf.io,mattclark/osf.io,sloria/osf.io,aaxelb/osf.io,aaxelb/osf.io,pattisdr/osf.io,erinspace/osf.io,CenterForOpenScience/osf.io,baylee-d/osf.io,HalcyonChimera/osf.io,laurenrevere/osf.io,chrisseto/osf.io,felliott/osf.io,leb2dg/osf.io,HalcyonChimera/osf.io,chennan47/osf.io,mfraezz/osf.io,Nesiehr/osf.io,cwisecarver/osf.io,binoculars/osf.io,hmoco/osf.io,TomBaxter/osf.io,brianjgeiger/osf.io,aaxelb/osf.io,chrisseto/osf.io,icereval/osf.io,Johnetordoff/osf.io,mfraezz/osf.io,felliott/osf.io,crcresearch/osf.io,hmoco/osf.io,cwisecarver/osf.io,chennan47/osf.io,cslzchen/osf.io,CenterForOpenScience/osf.io,leb2dg/osf.io,Johnetordoff/osf.io,pattisdr/osf.io,chrisseto/osf.io,CenterForOpenScience/osf.io,brianjgeiger/osf.io,leb2dg/osf.io,adlius/osf.io,sloria/osf.io,cslzchen/osf.io,caneruguz/osf.io,caseyrollins/osf.io,hmoco/osf.io,adlius/osf.io,binoculars/osf.io,crcresearch/osf.io,HalcyonChimera/osf.io,felliott/osf.io,cwisecarver/osf.io,cwisecarver/osf.io,caneruguz/osf.io,pattisdr/osf.io,caseyrollins/osf.io,TomBaxter/osf.io,Nesiehr/osf.io,laurenrevere/osf.io,Nesiehr/osf.io,chennan47/osf.io,adlius/osf.io,laurenrevere/osf.io,baylee-d/osf.io,baylee-d/osf.io,mfraezz/osf.io,cslzchen/osf.io,icereval/osf.io,caseyrollins/osf.io,icereval/osf.io,TomBaxter/osf.io,brianjgeiger/osf.io,caneruguz/osf.io,adlius/osf.io,leb2dg/osf.io,CenterForOpenScience/osf.io
|
from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institution/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
Update name of institution search URL route
|
from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institutions/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
|
<commit_before>from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institution/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
<commit_msg>Update name of institution search URL route<commit_after>
|
from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institutions/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
|
from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institution/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
Update name of institution search URL routefrom django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institutions/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
|
<commit_before>from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institution/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
<commit_msg>Update name of institution search URL route<commit_after>from django.conf.urls import url
from api.search import views
urlpatterns = [
url(r'^$', views.Search.as_view(), name=views.Search.view_name),
url(r'^components/$', views.SearchComponents.as_view(), name=views.SearchComponents.view_name),
url(r'^files/$', views.SearchFiles.as_view(), name=views.SearchFiles.view_name),
url(r'^projects/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
url(r'^registrations/$', views.SearchRegistrations.as_view(), name=views.SearchRegistrations.view_name),
url(r'^users/$', views.SearchUsers.as_view(), name=views.SearchUsers.view_name),
url(r'^institutions/$', views.SearchInstitutions.as_view(), name=views.SearchInstitutions.view_name),
# not currently supported by v1, but should be supported by v2
# url(r'^nodes/$', views.SearchProjects.as_view(), name=views.SearchProjects.view_name),
]
|
fb39b3ffc6fcd3df0f89cd3978796a4377335075
|
tests/primitives/utils.py
|
tests/primitives/utils.py
|
import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
|
import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert actual_ciphertext == binascii.unhexlify(ciphertext)
|
Rewrite to avoid capitalization issues
|
Rewrite to avoid capitalization issues
|
Python
|
bsd-3-clause
|
kimvais/cryptography,Ayrx/cryptography,dstufft/cryptography,sholsapp/cryptography,dstufft/cryptography,bwhmather/cryptography,sholsapp/cryptography,kimvais/cryptography,kimvais/cryptography,Lukasa/cryptography,skeuomorf/cryptography,sholsapp/cryptography,Hasimir/cryptography,skeuomorf/cryptography,Lukasa/cryptography,dstufft/cryptography,Hasimir/cryptography,glyph/cryptography,bwhmather/cryptography,kimvais/cryptography,skeuomorf/cryptography,sholsapp/cryptography,Hasimir/cryptography,Lukasa/cryptography,Ayrx/cryptography,skeuomorf/cryptography,Ayrx/cryptography,Ayrx/cryptography,dstufft/cryptography,glyph/cryptography,bwhmather/cryptography,Hasimir/cryptography,bwhmather/cryptography,dstufft/cryptography
|
import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
Rewrite to avoid capitalization issues
|
import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert actual_ciphertext == binascii.unhexlify(ciphertext)
|
<commit_before>import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
<commit_msg>Rewrite to avoid capitalization issues<commit_after>
|
import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert actual_ciphertext == binascii.unhexlify(ciphertext)
|
import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
Rewrite to avoid capitalization issuesimport binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert actual_ciphertext == binascii.unhexlify(ciphertext)
|
<commit_before>import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert binascii.hexlify(actual_ciphertext) == ciphertext
<commit_msg>Rewrite to avoid capitalization issues<commit_after>import binascii
import os
import pytest
from cryptography.bindings import _ALL_APIS
from cryptography.primitives.block import BlockCipher
def generate_encrypt_test(param_loader, path, file_names, cipher_factory,
mode_factory, only_if=lambda api: True,
skip_message=None):
def test_encryption(self):
for api in _ALL_APIS:
for file_name in file_names:
for params in param_loader(os.path.join(path, file_name)):
yield (
encrypt_test,
api,
cipher_factory,
mode_factory,
params,
only_if,
skip_message
)
return test_encryption
def encrypt_test(api, cipher_factory, mode_factory, params, only_if,
skip_message):
if not only_if(api):
pytest.skip(skip_message)
plaintext = params.pop("plaintext")
ciphertext = params.pop("ciphertext")
cipher = BlockCipher(
cipher_factory(**params),
mode_factory(**params),
api
)
actual_ciphertext = cipher.encrypt(binascii.unhexlify(plaintext))
actual_ciphertext += cipher.finalize()
assert actual_ciphertext == binascii.unhexlify(ciphertext)
|
010040a8f7cb6a7a60b88ae80c43198fc46594d9
|
tests/test_integration.py
|
tests/test_integration.py
|
import os
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.get_zones()
self.assertIsInstance(zones, list)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
|
import os
import types
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.iter_zones()
self.assertIsInstance(zones, types.GeneratorType)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
|
Test iter_zones instead of get_zones
|
Test iter_zones instead of get_zones
|
Python
|
mit
|
yola/pycloudflare,gnowxilef/pycloudflare
|
import os
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.get_zones()
self.assertIsInstance(zones, list)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
Test iter_zones instead of get_zones
|
import os
import types
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.iter_zones()
self.assertIsInstance(zones, types.GeneratorType)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
|
<commit_before>import os
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.get_zones()
self.assertIsInstance(zones, list)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
<commit_msg>Test iter_zones instead of get_zones<commit_after>
|
import os
import types
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.iter_zones()
self.assertIsInstance(zones, types.GeneratorType)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
|
import os
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.get_zones()
self.assertIsInstance(zones, list)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
Test iter_zones instead of get_zonesimport os
import types
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.iter_zones()
self.assertIsInstance(zones, types.GeneratorType)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
|
<commit_before>import os
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.get_zones()
self.assertIsInstance(zones, list)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
<commit_msg>Test iter_zones instead of get_zones<commit_after>import os
import types
from unittest import TestCase
from yoconfigurator.base import read_config
from yoconfig import configure_services
from pycloudflare.services import CloudFlareService
app_dir = os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))
conf = read_config(app_dir)
class ZonesTest(TestCase):
def setUp(self):
configure_services('cloudflare', ['cloudflare'], conf.common)
self.cloudflare = CloudFlareService()
def test_get_all_zones(self):
zones = self.cloudflare.iter_zones()
self.assertIsInstance(zones, types.GeneratorType)
def test_get_zone(self):
zone_id = self.cloudflare.get_zones()[0]['id']
zone = self.cloudflare.get_zone(zone_id)
self.assertIsInstance(zone, dict)
|
582da24725e03a159aa47cdf730915cddab52c5d
|
workflows/cp-leaveout/scripts/print-node-info.py
|
workflows/cp-leaveout/scripts/print-node-info.py
|
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import abort
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
abort(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
|
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import fail
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
fail(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
|
Replace abort() with fail() again
|
Replace abort() with fail() again
|
Python
|
mit
|
ECP-CANDLE/Supervisor,ECP-CANDLE/Supervisor,ECP-CANDLE/Supervisor,ECP-CANDLE/Supervisor,ECP-CANDLE/Supervisor,ECP-CANDLE/Supervisor
|
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import abort
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
abort(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
Replace abort() with fail() again
|
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import fail
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
fail(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
|
<commit_before>
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import abort
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
abort(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
<commit_msg>Replace abort() with fail() again<commit_after>
|
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import fail
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
fail(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
|
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import abort
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
abort(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
Replace abort() with fail() again
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import fail
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
fail(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
|
<commit_before>
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import abort
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
abort(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
<commit_msg>Replace abort() with fail() again<commit_after>
# EXTRACT NODE INFO PY
import argparse, os, pickle, sys
from Node import Node
from utils import fail
parser = argparse.ArgumentParser(description='Parse all log files')
parser.add_argument('directory',
help='The experiment directory (EXPID)')
args = parser.parse_args()
node_pkl = args.directory + "/node-info.pkl"
try:
with open(node_pkl, 'rb') as fp:
data = pickle.load(fp)
except IOError as e:
fail(e, os.EX_IOERR, "Could not read: " + node_pkl)
# print(data)
for item in data.values():
print(item.str_table())
# print(len(data))
|
1e219dc666c91a54f072ec0f2107942c4150bbd6
|
fabfile.py
|
fabfile.py
|
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
|
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("workon ga")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
|
Install in correct virtual environment in test server
|
Install in correct virtual environment in test server
|
Python
|
agpl-3.0
|
andresmrm/gastos_abertos,nucleo-digital/gastos_abertos,andresmrm/gastos_abertos,LuizArmesto/gastos_abertos,okfn-brasil/gastos_abertos,okfn-brasil/gastos_abertos,LuizArmesto/gastos_abertos
|
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
Install in correct virtual environment in test server
|
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("workon ga")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
|
<commit_before># -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
<commit_msg>Install in correct virtual environment in test server<commit_after>
|
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("workon ga")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
|
# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
Install in correct virtual environment in test server# -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("workon ga")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
|
<commit_before># -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
<commit_msg>Install in correct virtual environment in test server<commit_after># -*- coding: utf-8 -*-
# http://docs.fabfile.org/en/1.5/tutorial.html
from fabric.api import *
from fabric.network import ssh
project = "gastosabertos"
env.user = 'gastosabertos'
env.hosts = ['gastosabertos.org']
#env.key_filename = '~/.ssh/ga_id_rsa'
def reset():
"""
Reset local debug env.
"""
local("rm -rf /tmp/instance")
local("mkdir /tmp/instance")
def setup():
"""
Setup virtual env.
"""
local("virtualenv env")
activate_this = "env/bin/activate_this.py"
execfile(activate_this, dict(__file__=activate_this))
local("python setup.py install")
reset()
def deploy():
"""
Deploy project to Gastos Abertos server
"""
project_dir = '/home/gastosabertos/gastos_abertos'
with cd(project_dir):
run("git pull")
run("workon ga")
run("python setup.py install")
run("touch wsgi.py")
def d():
"""
Debug.
"""
reset()
local("python manage.py run")
def babel():
"""
Babel compile.
"""
local("python setup.py compile_catalog --directory `find -name translations` --locale zh -f")
|
c40d63852807645a39bb1e3316a10e5f2a3ad650
|
syntacticframes_project/loadmapping/management/commands/save_correspondances.py
|
syntacticframes_project/loadmapping/management/commands/save_correspondances.py
|
import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LADL', 'LVF', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.ladl_string, root_fs.lvf_string,
root_fs.paragon, root_fs.comment])
|
import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LVF', 'LADL', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.lvf_string, root_fs.ladl_string,
root_fs.paragon, root_fs.comment])
|
Save LVF before LADL in CSV to be similar to website
|
Save LVF before LADL in CSV to be similar to website
|
Python
|
mit
|
aymara/verbenet-editor,aymara/verbenet-editor,aymara/verbenet-editor
|
import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LADL', 'LVF', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.ladl_string, root_fs.lvf_string,
root_fs.paragon, root_fs.comment])
Save LVF before LADL in CSV to be similar to website
|
import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LVF', 'LADL', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.lvf_string, root_fs.ladl_string,
root_fs.paragon, root_fs.comment])
|
<commit_before>import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LADL', 'LVF', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.ladl_string, root_fs.lvf_string,
root_fs.paragon, root_fs.comment])
<commit_msg>Save LVF before LADL in CSV to be similar to website<commit_after>
|
import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LVF', 'LADL', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.lvf_string, root_fs.ladl_string,
root_fs.paragon, root_fs.comment])
|
import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LADL', 'LVF', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.ladl_string, root_fs.lvf_string,
root_fs.paragon, root_fs.comment])
Save LVF before LADL in CSV to be similar to websiteimport csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LVF', 'LADL', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.lvf_string, root_fs.ladl_string,
root_fs.paragon, root_fs.comment])
|
<commit_before>import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LADL', 'LVF', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.ladl_string, root_fs.lvf_string,
root_fs.paragon, root_fs.comment])
<commit_msg>Save LVF before LADL in CSV to be similar to website<commit_after>import csv
from os import path
from distutils.version import LooseVersion
from django.core.management.base import BaseCommand
from django.conf import settings
from syntacticframes.models import VerbNetClass
class Command(BaseCommand):
def handle(self, *args, **options):
with open(path.join(settings.SITE_ROOT, 'loadmapping/resources/Correspondances.csv'), 'w') as csvfile:
correswriter = csv.writer(csvfile)
correswriter.writerow(['VerbNet', 'LVF', 'LADL', 'Parangon', 'Commentaires'])
for vn_class in sorted(VerbNetClass.objects.all(), key = lambda v: LooseVersion(v.name.split('-')[1])):
root_fs = vn_class.verbnetframeset_set.get(parent=None)
correswriter.writerow(["{}: {}".format(vn_class.name.split('-')[1], vn_class.name),
root_fs.lvf_string, root_fs.ladl_string,
root_fs.paragon, root_fs.comment])
|
9a57f2493a8e7561a053077c793cdd998c9a28c9
|
bucketeer/test/test_commit.py
|
bucketeer/test/test_commit.py
|
import unittest
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# 1 bucket with 1 file
return
def tearDown(self):
# Remove all test-created buckets and files
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
|
import unittest
import boto
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# Create a bucket with one file
connection = boto.connect_s3()
bucket = connection.create_bucket('bucket.exists')
return
def tearDown(self):
# Remove all test-created buckets and files
connection = boto.connect_s3()
bucket = connection.delete_bucket('bucket.exists')
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
|
Add setUp and tearDown of a test bucket
|
Add setUp and tearDown of a test bucket
|
Python
|
mit
|
mgarbacz/bucketeer
|
import unittest
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# 1 bucket with 1 file
return
def tearDown(self):
# Remove all test-created buckets and files
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
Add setUp and tearDown of a test bucket
|
import unittest
import boto
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# Create a bucket with one file
connection = boto.connect_s3()
bucket = connection.create_bucket('bucket.exists')
return
def tearDown(self):
# Remove all test-created buckets and files
connection = boto.connect_s3()
bucket = connection.delete_bucket('bucket.exists')
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
|
<commit_before>import unittest
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# 1 bucket with 1 file
return
def tearDown(self):
# Remove all test-created buckets and files
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
<commit_msg>Add setUp and tearDown of a test bucket<commit_after>
|
import unittest
import boto
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# Create a bucket with one file
connection = boto.connect_s3()
bucket = connection.create_bucket('bucket.exists')
return
def tearDown(self):
# Remove all test-created buckets and files
connection = boto.connect_s3()
bucket = connection.delete_bucket('bucket.exists')
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
|
import unittest
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# 1 bucket with 1 file
return
def tearDown(self):
# Remove all test-created buckets and files
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
Add setUp and tearDown of a test bucketimport unittest
import boto
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# Create a bucket with one file
connection = boto.connect_s3()
bucket = connection.create_bucket('bucket.exists')
return
def tearDown(self):
# Remove all test-created buckets and files
connection = boto.connect_s3()
bucket = connection.delete_bucket('bucket.exists')
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
|
<commit_before>import unittest
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# 1 bucket with 1 file
return
def tearDown(self):
# Remove all test-created buckets and files
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
<commit_msg>Add setUp and tearDown of a test bucket<commit_after>import unittest
import boto
from bucketeer import commit
class BuckeeterTest(unittest.TestCase):
def setUp(self):
# Create a bucket with one file
connection = boto.connect_s3()
bucket = connection.create_bucket('bucket.exists')
return
def tearDown(self):
# Remove all test-created buckets and files
connection = boto.connect_s3()
bucket = connection.delete_bucket('bucket.exists')
return
def testMain(self):
self.assertTrue(commit)
if __name__ == '__main__':
unittest.main()
|
860e23b6c854ea5a5babb774328e5359d346c80a
|
contact_form/forms.py
|
contact_form/forms.py
|
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for email, _ in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass
|
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for _, email in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass
|
Make email and name order fit to the default django settings file
|
Make email and name order fit to the default django settings file
|
Python
|
bsd-3-clause
|
alainivars/django-contact-form,alainivars/django-contact-form,madisona/django-contact-form,madisona/django-contact-form
|
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for email, _ in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
passMake email and name order fit to the default django settings file
|
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for _, email in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass
|
<commit_before>
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for email, _ in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass<commit_msg>Make email and name order fit to the default django settings file<commit_after>
|
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for _, email in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass
|
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for email, _ in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
passMake email and name order fit to the default django settings file
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for _, email in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass
|
<commit_before>
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for email, _ in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass<commit_msg>Make email and name order fit to the default django settings file<commit_after>
from django import forms
from django.conf import settings
from django.template import loader
from django.core.mail import send_mail
class BaseEmailFormMixin(object):
from_email = settings.DEFAULT_FROM_EMAIL
recipient_list = [email for _, email in settings.MANAGERS]
subject_template_name = 'contact_form/email_subject.txt'
message_template_name = 'contact_form/email_template.txt'
def get_message(self):
return loader.render_to_string(self.message_template_name, self.get_context())
def get_subject(self):
subject = loader.render_to_string(self.subject_template_name, self.get_context())
return ''.join(subject.splitlines())
def get_context(self):
if not self.is_valid():
raise ValueError("Cannot generate Context when form is invalid.")
return self.cleaned_data
def get_message_dict(self):
return {
"from_email": self.from_email,
"recipient_list": self.recipient_list,
"subject": self.get_subject(),
"message": self.get_message(),
}
def send_email(self, request, fail_silently=False):
self.request = request
send_mail(fail_silently=fail_silently, **self.get_message_dict())
class ContactForm(forms.Form, BaseEmailFormMixin):
pass
class ContactModelForm(forms.ModelForm, BaseEmailFormMixin):
"""
You'll need to declare the model yourself.
"""
pass
|
84af44868ea742bb5f6d08991526a98c8c78a931
|
tellurium/teconverters/__init__.py
|
tellurium/teconverters/__init__.py
|
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
except:
pass
from .antimony_sbo import SBOError
from .inline_omex import inlineOmex, saveInlineOMEX
|
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
from .inline_omex import inlineOmex, saveInlineOMEX
except:
pass
from .antimony_sbo import SBOError
|
Drop inline omex if it fails.
|
Drop inline omex if it fails.
|
Python
|
apache-2.0
|
sys-bio/tellurium,sys-bio/tellurium
|
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
except:
pass
from .antimony_sbo import SBOError
from .inline_omex import inlineOmex, saveInlineOMEX
Drop inline omex if it fails.
|
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
from .inline_omex import inlineOmex, saveInlineOMEX
except:
pass
from .antimony_sbo import SBOError
|
<commit_before>
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
except:
pass
from .antimony_sbo import SBOError
from .inline_omex import inlineOmex, saveInlineOMEX
<commit_msg>Drop inline omex if it fails.<commit_after>
|
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
from .inline_omex import inlineOmex, saveInlineOMEX
except:
pass
from .antimony_sbo import SBOError
|
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
except:
pass
from .antimony_sbo import SBOError
from .inline_omex import inlineOmex, saveInlineOMEX
Drop inline omex if it fails.
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
from .inline_omex import inlineOmex, saveInlineOMEX
except:
pass
from .antimony_sbo import SBOError
|
<commit_before>
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
except:
pass
from .antimony_sbo import SBOError
from .inline_omex import inlineOmex, saveInlineOMEX
<commit_msg>Drop inline omex if it fails.<commit_after>
from __future__ import absolute_import
# converts Antimony to/from SBML
from .convert_antimony import antimonyConverter
from .convert_omex import inlineOmexImporter, OmexFormatDetector
try:
from .convert_phrasedml import phrasedmlImporter
from .inline_omex import inlineOmex, saveInlineOMEX
except:
pass
from .antimony_sbo import SBOError
|
69b262f502bbc48204db70815476aa256bd7db6e
|
rmgpy/tools/canteraTest.py
|
rmgpy/tools/canteraTest.py
|
import unittest
import os
import numpy
from rmgpy.tools.canteraModel import *
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
|
import unittest
import os
import numpy
from rmgpy.tools.canteraModel import findIgnitionDelay, CanteraCondition, Cantera
from rmgpy.quantity import Quantity
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
def testRepr(self):
"""
Test that the repr function for a CanteraCondition object can reconstitute
the same object
"""
reactorType='IdealGasReactor'
molFrac={'CC': 0.05, '[Ar]': 0.95}
P=(3,'atm')
T=(1500,'K')
terminationTime=(5e-5,'s')
condition = CanteraCondition(reactorType,
terminationTime,
molFrac,
T0=T,
P0=P)
reprCondition=eval(condition.__repr__())
self.assertEqual(reprCondition.T0.value_si,Quantity(T).value_si)
self.assertEqual(reprCondition.P0.value_si,Quantity(P).value_si)
self.assertEqual(reprCondition.V0,None)
self.assertEqual(reprCondition.molFrac,molFrac)
|
Add unit test for CanteraCondition that tests that the repr() function works
|
Add unit test for CanteraCondition that tests that the repr() function works
|
Python
|
mit
|
nyee/RMG-Py,nickvandewiele/RMG-Py,chatelak/RMG-Py,nickvandewiele/RMG-Py,chatelak/RMG-Py,nyee/RMG-Py,pierrelb/RMG-Py,pierrelb/RMG-Py
|
import unittest
import os
import numpy
from rmgpy.tools.canteraModel import *
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
Add unit test for CanteraCondition that tests that the repr() function works
|
import unittest
import os
import numpy
from rmgpy.tools.canteraModel import findIgnitionDelay, CanteraCondition, Cantera
from rmgpy.quantity import Quantity
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
def testRepr(self):
"""
Test that the repr function for a CanteraCondition object can reconstitute
the same object
"""
reactorType='IdealGasReactor'
molFrac={'CC': 0.05, '[Ar]': 0.95}
P=(3,'atm')
T=(1500,'K')
terminationTime=(5e-5,'s')
condition = CanteraCondition(reactorType,
terminationTime,
molFrac,
T0=T,
P0=P)
reprCondition=eval(condition.__repr__())
self.assertEqual(reprCondition.T0.value_si,Quantity(T).value_si)
self.assertEqual(reprCondition.P0.value_si,Quantity(P).value_si)
self.assertEqual(reprCondition.V0,None)
self.assertEqual(reprCondition.molFrac,molFrac)
|
<commit_before>import unittest
import os
import numpy
from rmgpy.tools.canteraModel import *
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
<commit_msg>Add unit test for CanteraCondition that tests that the repr() function works<commit_after>
|
import unittest
import os
import numpy
from rmgpy.tools.canteraModel import findIgnitionDelay, CanteraCondition, Cantera
from rmgpy.quantity import Quantity
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
def testRepr(self):
"""
Test that the repr function for a CanteraCondition object can reconstitute
the same object
"""
reactorType='IdealGasReactor'
molFrac={'CC': 0.05, '[Ar]': 0.95}
P=(3,'atm')
T=(1500,'K')
terminationTime=(5e-5,'s')
condition = CanteraCondition(reactorType,
terminationTime,
molFrac,
T0=T,
P0=P)
reprCondition=eval(condition.__repr__())
self.assertEqual(reprCondition.T0.value_si,Quantity(T).value_si)
self.assertEqual(reprCondition.P0.value_si,Quantity(P).value_si)
self.assertEqual(reprCondition.V0,None)
self.assertEqual(reprCondition.molFrac,molFrac)
|
import unittest
import os
import numpy
from rmgpy.tools.canteraModel import *
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
Add unit test for CanteraCondition that tests that the repr() function worksimport unittest
import os
import numpy
from rmgpy.tools.canteraModel import findIgnitionDelay, CanteraCondition, Cantera
from rmgpy.quantity import Quantity
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
def testRepr(self):
"""
Test that the repr function for a CanteraCondition object can reconstitute
the same object
"""
reactorType='IdealGasReactor'
molFrac={'CC': 0.05, '[Ar]': 0.95}
P=(3,'atm')
T=(1500,'K')
terminationTime=(5e-5,'s')
condition = CanteraCondition(reactorType,
terminationTime,
molFrac,
T0=T,
P0=P)
reprCondition=eval(condition.__repr__())
self.assertEqual(reprCondition.T0.value_si,Quantity(T).value_si)
self.assertEqual(reprCondition.P0.value_si,Quantity(P).value_si)
self.assertEqual(reprCondition.V0,None)
self.assertEqual(reprCondition.molFrac,molFrac)
|
<commit_before>import unittest
import os
import numpy
from rmgpy.tools.canteraModel import *
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
<commit_msg>Add unit test for CanteraCondition that tests that the repr() function works<commit_after>import unittest
import os
import numpy
from rmgpy.tools.canteraModel import findIgnitionDelay, CanteraCondition, Cantera
from rmgpy.quantity import Quantity
class CanteraTest(unittest.TestCase):
def testIgnitionDelay(self):
"""
Test that findIgnitionDelay() works.
"""
t = numpy.arange(0,5,0.5)
P = numpy.array([0,0.33,0.5,0.9,2,4,15,16,16.1,16.2])
OH = numpy.array([0,0.33,0.5,0.9,2,4,15,16,7,2])
CO = OH*0.9
t_ign = findIgnitionDelay(t,P)
self.assertEqual(t_ign,2.75)
t_ign = findIgnitionDelay(t,OH,'maxHalfConcentration')
self.assertEqual(t_ign,3)
t_ign = findIgnitionDelay(t,[OH,CO], 'maxSpeciesConcentrations')
self.assertEqual(t_ign,3.5)
def testRepr(self):
"""
Test that the repr function for a CanteraCondition object can reconstitute
the same object
"""
reactorType='IdealGasReactor'
molFrac={'CC': 0.05, '[Ar]': 0.95}
P=(3,'atm')
T=(1500,'K')
terminationTime=(5e-5,'s')
condition = CanteraCondition(reactorType,
terminationTime,
molFrac,
T0=T,
P0=P)
reprCondition=eval(condition.__repr__())
self.assertEqual(reprCondition.T0.value_si,Quantity(T).value_si)
self.assertEqual(reprCondition.P0.value_si,Quantity(P).value_si)
self.assertEqual(reprCondition.V0,None)
self.assertEqual(reprCondition.molFrac,molFrac)
|
6daaaa8dd16d088cde21fd4d55e91d97602f4cfd
|
drivers/python/setup.py
|
drivers/python/setup.py
|
# Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-0"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
|
# Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-1"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
|
Update python driver version to 1.4.0-1
|
Update python driver version to 1.4.0-1
|
Python
|
agpl-3.0
|
dparnell/rethinkdb,RubenKelevra/rethinkdb,victorbriz/rethinkdb,bchavez/rethinkdb,elkingtonmcb/rethinkdb,ajose01/rethinkdb,Qinusty/rethinkdb,spblightadv/rethinkdb,lenstr/rethinkdb,alash3al/rethinkdb,gavioto/rethinkdb,marshall007/rethinkdb,Qinusty/rethinkdb,gdi2290/rethinkdb,niieani/rethinkdb,bchavez/rethinkdb,bpradipt/rethinkdb,jesseditson/rethinkdb,gdi2290/rethinkdb,wojons/rethinkdb,wojons/rethinkdb,pap/rethinkdb,wojons/rethinkdb,gavioto/rethinkdb,sbusso/rethinkdb,urandu/rethinkdb,matthaywardwebdesign/rethinkdb,gdi2290/rethinkdb,losywee/rethinkdb,jesseditson/rethinkdb,jmptrader/rethinkdb,tempbottle/rethinkdb,gavioto/rethinkdb,captainpete/rethinkdb,gavioto/rethinkdb,urandu/rethinkdb,wkennington/rethinkdb,pap/rethinkdb,victorbriz/rethinkdb,KSanthanam/rethinkdb,gdi2290/rethinkdb,mbroadst/rethinkdb,losywee/rethinkdb,yaolinz/rethinkdb,grandquista/rethinkdb,urandu/rethinkdb,greyhwndz/rethinkdb,sontek/rethinkdb,sbusso/rethinkdb,KSanthanam/rethinkdb,sebadiaz/rethinkdb,grandquista/rethinkdb,RubenKelevra/rethinkdb,bpradipt/rethinkdb,KSanthanam/rethinkdb,niieani/rethinkdb,dparnell/rethinkdb,Wilbeibi/rethinkdb,niieani/rethinkdb,victorbriz/rethinkdb,yakovenkodenis/rethinkdb,mbroadst/rethinkdb,captainpete/rethinkdb,mbroadst/rethinkdb,4talesa/rethinkdb,urandu/rethinkdb,lenstr/rethinkdb,AtnNn/rethinkdb,urandu/rethinkdb,gavioto/rethinkdb,rrampage/rethinkdb,JackieXie168/rethinkdb,Qinusty/rethinkdb,robertjpayne/rethinkdb,mbroadst/rethinkdb,tempbottle/rethinkdb,marshall007/rethinkdb,ayumilong/rethinkdb,spblightadv/rethinkdb,KSanthanam/rethinkdb,rrampage/rethinkdb,wujf/rethinkdb,Wilbeibi/rethinkdb,4talesa/rethinkdb,sbusso/rethinkdb,spblightadv/rethinkdb,niieani/rethinkdb,dparnell/rethinkdb,pap/rethinkdb,losywee/rethinkdb,elkingtonmcb/rethinkdb,captainpete/rethinkdb,robertjpayne/rethinkdb,jesseditson/rethinkdb,JackieXie168/rethinkdb,jmptrader/rethinkdb,scripni/rethinkdb,ajose01/rethinkdb,spblightadv/rethinkdb,grandquista/rethinkdb,AntouanK/rethinkdb,eliangidoni/rethinkdb,grandquista/rethinkdb,gavioto/rethinkdb,Wilbeibi/rethinkdb,robertjpayne/rethinkdb,RubenKelevra/rethinkdb,wojons/rethinkdb,pap/rethinkdb,lenstr/rethinkdb,wojons/rethinkdb,victorbriz/rethinkdb,elkingtonmcb/rethinkdb,wkennington/rethinkdb,mcanthony/rethinkdb,niieani/rethinkdb,scripni/rethinkdb,mquandalle/rethinkdb,AtnNn/rethinkdb,Qinusty/rethinkdb,sebadiaz/rethinkdb,mcanthony/rethinkdb,alash3al/rethinkdb,matthaywardwebdesign/rethinkdb,JackieXie168/rethinkdb,RubenKelevra/rethinkdb,urandu/rethinkdb,victorbriz/rethinkdb,alash3al/rethinkdb,mbroadst/rethinkdb,greyhwndz/rethinkdb,rrampage/rethinkdb,urandu/rethinkdb,eliangidoni/rethinkdb,RubenKelevra/rethinkdb,AntouanK/rethinkdb,eliangidoni/rethinkdb,bpradipt/rethinkdb,elkingtonmcb/rethinkdb,catroot/rethinkdb,mquandalle/rethinkdb,gdi2290/rethinkdb,scripni/rethinkdb,catroot/rethinkdb,alash3al/rethinkdb,losywee/rethinkdb,JackieXie168/rethinkdb,matthaywardwebdesign/rethinkdb,yaolinz/rethinkdb,captainpete/rethinkdb,AtnNn/rethinkdb,robertjpayne/rethinkdb,wkennington/rethinkdb,JackieXie168/rethinkdb,yakovenkodenis/rethinkdb,jesseditson/rethinkdb,rrampage/rethinkdb,yaolinz/rethinkdb,lenstr/rethinkdb,catroot/rethinkdb,mquandalle/rethinkdb,greyhwndz/rethinkdb,yaolinz/rethinkdb,yakovenkodenis/rethinkdb,captainpete/rethinkdb,elkingtonmcb/rethinkdb,mbroadst/rethinkdb,spblightadv/rethinkdb,mcanthony/rethinkdb,pap/rethinkdb,gdi2290/rethinkdb,pap/rethinkdb,sontek/rethinkdb,KSanthanam/rethinkdb,catroot/rethinkdb,ajose01/rethinkdb,sbusso/rethinkdb,jmptrader/rethinkdb,AntouanK/rethinkdb,yakovenkodenis/rethinkdb,robertjpayne/rethinkdb,elkingtonmcb/rethinkdb,yakovenkodenis/rethinkdb,eliangidoni/rethinkdb,sbusso/rethinkdb,catroot/rethinkdb,grandquista/rethinkdb,ayumilong/rethinkdb,sontek/rethinkdb,bpradipt/rethinkdb,matthaywardwebdesign/rethinkdb,jesseditson/rethinkdb,jmptrader/rethinkdb,marshall007/rethinkdb,matthaywardwebdesign/rethinkdb,ajose01/rethinkdb,dparnell/rethinkdb,victorbriz/rethinkdb,yaolinz/rethinkdb,eliangidoni/rethinkdb,4talesa/rethinkdb,4talesa/rethinkdb,lenstr/rethinkdb,tempbottle/rethinkdb,victorbriz/rethinkdb,yaolinz/rethinkdb,sbusso/rethinkdb,bpradipt/rethinkdb,yaolinz/rethinkdb,AtnNn/rethinkdb,sebadiaz/rethinkdb,scripni/rethinkdb,niieani/rethinkdb,ajose01/rethinkdb,alash3al/rethinkdb,Qinusty/rethinkdb,sontek/rethinkdb,mquandalle/rethinkdb,sbusso/rethinkdb,AtnNn/rethinkdb,niieani/rethinkdb,4talesa/rethinkdb,wujf/rethinkdb,AntouanK/rethinkdb,greyhwndz/rethinkdb,robertjpayne/rethinkdb,AntouanK/rethinkdb,JackieXie168/rethinkdb,bchavez/rethinkdb,marshall007/rethinkdb,dparnell/rethinkdb,spblightadv/rethinkdb,mquandalle/rethinkdb,ayumilong/rethinkdb,rrampage/rethinkdb,alash3al/rethinkdb,rrampage/rethinkdb,sontek/rethinkdb,catroot/rethinkdb,wkennington/rethinkdb,matthaywardwebdesign/rethinkdb,pap/rethinkdb,Qinusty/rethinkdb,grandquista/rethinkdb,pap/rethinkdb,tempbottle/rethinkdb,eliangidoni/rethinkdb,wujf/rethinkdb,losywee/rethinkdb,elkingtonmcb/rethinkdb,Wilbeibi/rethinkdb,wkennington/rethinkdb,wujf/rethinkdb,mquandalle/rethinkdb,robertjpayne/rethinkdb,Qinusty/rethinkdb,ayumilong/rethinkdb,captainpete/rethinkdb,AtnNn/rethinkdb,greyhwndz/rethinkdb,sebadiaz/rethinkdb,catroot/rethinkdb,sebadiaz/rethinkdb,tempbottle/rethinkdb,yaolinz/rethinkdb,mcanthony/rethinkdb,niieani/rethinkdb,wujf/rethinkdb,sontek/rethinkdb,Qinusty/rethinkdb,wkennington/rethinkdb,bchavez/rethinkdb,dparnell/rethinkdb,Wilbeibi/rethinkdb,ayumilong/rethinkdb,bpradipt/rethinkdb,ajose01/rethinkdb,mquandalle/rethinkdb,sontek/rethinkdb,scripni/rethinkdb,rrampage/rethinkdb,mcanthony/rethinkdb,rrampage/rethinkdb,lenstr/rethinkdb,jmptrader/rethinkdb,elkingtonmcb/rethinkdb,marshall007/rethinkdb,sbusso/rethinkdb,Wilbeibi/rethinkdb,catroot/rethinkdb,JackieXie168/rethinkdb,wkennington/rethinkdb,victorbriz/rethinkdb,scripni/rethinkdb,wujf/rethinkdb,sebadiaz/rethinkdb,KSanthanam/rethinkdb,KSanthanam/rethinkdb,AntouanK/rethinkdb,bchavez/rethinkdb,mcanthony/rethinkdb,tempbottle/rethinkdb,tempbottle/rethinkdb,robertjpayne/rethinkdb,eliangidoni/rethinkdb,marshall007/rethinkdb,KSanthanam/rethinkdb,yakovenkodenis/rethinkdb,captainpete/rethinkdb,AtnNn/rethinkdb,jmptrader/rethinkdb,gavioto/rethinkdb,RubenKelevra/rethinkdb,JackieXie168/rethinkdb,yakovenkodenis/rethinkdb,wojons/rethinkdb,JackieXie168/rethinkdb,losywee/rethinkdb,AntouanK/rethinkdb,alash3al/rethinkdb,Wilbeibi/rethinkdb,jesseditson/rethinkdb,4talesa/rethinkdb,sebadiaz/rethinkdb,ayumilong/rethinkdb,gdi2290/rethinkdb,mbroadst/rethinkdb,losywee/rethinkdb,mbroadst/rethinkdb,matthaywardwebdesign/rethinkdb,grandquista/rethinkdb,jmptrader/rethinkdb,gavioto/rethinkdb,RubenKelevra/rethinkdb,alash3al/rethinkdb,4talesa/rethinkdb,bpradipt/rethinkdb,Wilbeibi/rethinkdb,lenstr/rethinkdb,spblightadv/rethinkdb,sontek/rethinkdb,Qinusty/rethinkdb,dparnell/rethinkdb,spblightadv/rethinkdb,urandu/rethinkdb,wujf/rethinkdb,marshall007/rethinkdb,wojons/rethinkdb,grandquista/rethinkdb,marshall007/rethinkdb,bchavez/rethinkdb,bchavez/rethinkdb,lenstr/rethinkdb,tempbottle/rethinkdb,AntouanK/rethinkdb,ajose01/rethinkdb,RubenKelevra/rethinkdb,ajose01/rethinkdb,mcanthony/rethinkdb,wkennington/rethinkdb,greyhwndz/rethinkdb,bchavez/rethinkdb,jesseditson/rethinkdb,robertjpayne/rethinkdb,matthaywardwebdesign/rethinkdb,grandquista/rethinkdb,losywee/rethinkdb,dparnell/rethinkdb,jmptrader/rethinkdb,sebadiaz/rethinkdb,bpradipt/rethinkdb,mcanthony/rethinkdb,AtnNn/rethinkdb,ayumilong/rethinkdb,greyhwndz/rethinkdb,scripni/rethinkdb,mquandalle/rethinkdb,scripni/rethinkdb,bchavez/rethinkdb,eliangidoni/rethinkdb,greyhwndz/rethinkdb,eliangidoni/rethinkdb,yakovenkodenis/rethinkdb,captainpete/rethinkdb,bpradipt/rethinkdb,jesseditson/rethinkdb,mbroadst/rethinkdb,ayumilong/rethinkdb,wojons/rethinkdb,4talesa/rethinkdb,dparnell/rethinkdb
|
# Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-0"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
Update python driver version to 1.4.0-1
|
# Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-1"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
|
<commit_before># Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-0"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
<commit_msg>Update python driver version to 1.4.0-1<commit_after>
|
# Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-1"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
|
# Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-0"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
Update python driver version to 1.4.0-1# Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-1"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
|
<commit_before># Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-0"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
<commit_msg>Update python driver version to 1.4.0-1<commit_after># Copyright 2010-2012 RethinkDB, all rights reserved.
from setuptools import setup
setup(name="rethinkdb"
,version="1.4.0-1"
,description="This package provides the Python driver library for the RethinkDB database server."
,url="http://rethinkdb.com"
,maintainer="RethinkDB Inc."
,maintainer_email="[email protected]"
,packages=['rethinkdb']
,install_requires=['protobuf']
)
|
ca919f7af3fe529209ea007612fd83fcd15832ef
|
pip_package/rlds_version.py
|
pip_package/rlds_version.py
|
# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '4'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
|
# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '5'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
|
Update RLDS to 0.1.5 (already uploaded to Pypi)
|
Update RLDS to 0.1.5 (already uploaded to Pypi)
PiperOrigin-RevId: 467605984
Change-Id: I421e884c38da5be935e085d5419642b8decf5373
|
Python
|
apache-2.0
|
google-research/rlds,google-research/rlds
|
# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '4'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
Update RLDS to 0.1.5 (already uploaded to Pypi)
PiperOrigin-RevId: 467605984
Change-Id: I421e884c38da5be935e085d5419642b8decf5373
|
# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '5'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
|
<commit_before># Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '4'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
<commit_msg>Update RLDS to 0.1.5 (already uploaded to Pypi)
PiperOrigin-RevId: 467605984
Change-Id: I421e884c38da5be935e085d5419642b8decf5373<commit_after>
|
# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '5'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
|
# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '4'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
Update RLDS to 0.1.5 (already uploaded to Pypi)
PiperOrigin-RevId: 467605984
Change-Id: I421e884c38da5be935e085d5419642b8decf5373# Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '5'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
|
<commit_before># Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '4'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
<commit_msg>Update RLDS to 0.1.5 (already uploaded to Pypi)
PiperOrigin-RevId: 467605984
Change-Id: I421e884c38da5be935e085d5419642b8decf5373<commit_after># Copyright 2022 Google LLC.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# coding=utf-8
"""Package metadata for RLDS.
This is kept in a separate module so that it can be imported from setup.py, at
a time when RLDS's dependencies may not have been installed yet.
"""
# We follow Semantic Versioning (https://semver.org/)
_MAJOR_VERSION = '0'
_MINOR_VERSION = '1'
_PATCH_VERSION = '5'
# Example: '0.4.2'
__version__ = '.'.join([_MAJOR_VERSION, _MINOR_VERSION, _PATCH_VERSION])
|
7e7f9da097563d8fbd407268093b56c2f10464a5
|
radar/radar/tests/validation/test_reset_password_validation.py
|
radar/radar/tests/validation/test_reset_password_validation.py
|
import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == 'password'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
|
import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': '2irPtfNUURf8G',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == '2irPtfNUURf8G'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def test_weak_password():
invalid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
|
Use stronger password in reset password test
|
Use stronger password in reset password test
|
Python
|
agpl-3.0
|
renalreg/radar,renalreg/radar,renalreg/radar,renalreg/radar
|
import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == 'password'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
Use stronger password in reset password test
|
import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': '2irPtfNUURf8G',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == '2irPtfNUURf8G'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def test_weak_password():
invalid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
|
<commit_before>import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == 'password'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
<commit_msg>Use stronger password in reset password test<commit_after>
|
import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': '2irPtfNUURf8G',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == '2irPtfNUURf8G'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def test_weak_password():
invalid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
|
import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == 'password'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
Use stronger password in reset password testimport pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': '2irPtfNUURf8G',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == '2irPtfNUURf8G'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def test_weak_password():
invalid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
|
<commit_before>import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == 'password'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
<commit_msg>Use stronger password in reset password test<commit_after>import pytest
from radar.validation.reset_password import ResetPasswordValidation
from radar.validation.core import ValidationError
from radar.tests.validation.helpers import validation_runner
def test_valid():
obj = valid({
'token': '12345',
'username': 'hello',
'password': '2irPtfNUURf8G',
})
assert obj['token'] == '12345'
assert obj['username'] == 'hello'
assert obj['password'] == '2irPtfNUURf8G'
def test_token_missing():
invalid({
'username': 'hello',
'password': 'password',
})
def test_username_missing():
invalid({
'token': '12345',
'password': 'password',
})
def test_password_missing():
invalid({
'token': '12345',
'username': 'hello',
})
def test_weak_password():
invalid({
'token': '12345',
'username': 'hello',
'password': 'password',
})
def invalid(obj, **kwargs):
with pytest.raises(ValidationError) as e:
valid(obj, **kwargs)
return e
def valid(obj, **kwargs):
return validation_runner(dict, ResetPasswordValidation, obj, **kwargs)
|
002d1ac1d2fcf88a7df46681ef7b3969f08e9a8f
|
qual/calendar.py
|
qual/calendar.py
|
from datetime import date
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(JulianCalendar, d)
|
from datetime import date, timedelta
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
def convert_to(self, calendar):
return calendar.from_date(self.date)
def __eq__(self, other):
return self.calendar == other.calendar and self.date == other.date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
def from_date(self, date):
return DateWithCalendar(ProlepticGregorianCalendar, date)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
d = d + timedelta(days=10)
return DateWithCalendar(JulianCalendar, d)
|
Allow conversion from Julian to ProlepticGregorian, also comparison of dates.
|
Allow conversion from Julian to ProlepticGregorian, also comparison of dates.
|
Python
|
apache-2.0
|
jwg4/qual,jwg4/calexicon
|
from datetime import date
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(JulianCalendar, d)
Allow conversion from Julian to ProlepticGregorian, also comparison of dates.
|
from datetime import date, timedelta
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
def convert_to(self, calendar):
return calendar.from_date(self.date)
def __eq__(self, other):
return self.calendar == other.calendar and self.date == other.date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
def from_date(self, date):
return DateWithCalendar(ProlepticGregorianCalendar, date)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
d = d + timedelta(days=10)
return DateWithCalendar(JulianCalendar, d)
|
<commit_before>from datetime import date
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(JulianCalendar, d)
<commit_msg>Allow conversion from Julian to ProlepticGregorian, also comparison of dates.<commit_after>
|
from datetime import date, timedelta
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
def convert_to(self, calendar):
return calendar.from_date(self.date)
def __eq__(self, other):
return self.calendar == other.calendar and self.date == other.date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
def from_date(self, date):
return DateWithCalendar(ProlepticGregorianCalendar, date)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
d = d + timedelta(days=10)
return DateWithCalendar(JulianCalendar, d)
|
from datetime import date
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(JulianCalendar, d)
Allow conversion from Julian to ProlepticGregorian, also comparison of dates.from datetime import date, timedelta
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
def convert_to(self, calendar):
return calendar.from_date(self.date)
def __eq__(self, other):
return self.calendar == other.calendar and self.date == other.date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
def from_date(self, date):
return DateWithCalendar(ProlepticGregorianCalendar, date)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
d = d + timedelta(days=10)
return DateWithCalendar(JulianCalendar, d)
|
<commit_before>from datetime import date
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(JulianCalendar, d)
<commit_msg>Allow conversion from Julian to ProlepticGregorian, also comparison of dates.<commit_after>from datetime import date, timedelta
class DateWithCalendar(object):
def __init__(self, calendar_class, date):
self.calendar = calendar_class
self.date = date
def convert_to(self, calendar):
return calendar.from_date(self.date)
def __eq__(self, other):
return self.calendar == other.calendar and self.date == other.date
class ProlepticGregorianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
return DateWithCalendar(ProlepticGregorianCalendar, d)
def from_date(self, date):
return DateWithCalendar(ProlepticGregorianCalendar, date)
class JulianCalendar(object):
def date(self, year, month, day):
d = date(year, month, day)
d = d + timedelta(days=10)
return DateWithCalendar(JulianCalendar, d)
|
99c8473b0d1f778830c642c0f0e2b6c5bc1f3c80
|
plugins/plugin_count_ip.py
|
plugins/plugin_count_ip.py
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.total_ip = 0
self.ip_dict = {}
def __process_doc(self, **kwargs):
if 'host' in kwargs:
if self.ip_dict.has_key(kwargs['host']):
self.ip_dict[kwargs['host']] += 1
else:
self.ip_dict[kwargs['host']] = 1
self.total_ip += 1
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
# Do more HERE
for log_doc in collection.find(condition):
self.__process_doc(**log_doc)
def report(self, **kwargs):
print '== IP counter =='
print "HTTP IPs: %d" % self.total_ip
for ip in self.ip_dict.keys():
print "%s: %d" % (ip, self.ip_dict[ip])
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
from bson.code import Code
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.result = {}
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
reducer = Code("""
function(curr,result){
result.count++;
}
""")
host_result = collection.group(
key = {"host":1},
condition = condition,
initial = {"count":0},
reduce = reducer)
self.result[collection.name] = host_result
# mongo shell command
#db.runCommand({group:{ ns:"www_ename_cn_access", key:{host:1}, $reduce:function(curr,result){result.times += 1}, initial:{"times":0}}})
#db.news_ename_cn_access.group({key:{host:1},reduce:function(curr,result){result.times += 1;},initial:{times:0}})
def report(self, **kwargs):
print '== IP counter =='
print self.result
|
Add plugin count ip using mongo aggregation framework
|
Add plugin count ip using mongo aggregation framework
|
Python
|
apache-2.0
|
keepzero/fluent-mongo-parser
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.total_ip = 0
self.ip_dict = {}
def __process_doc(self, **kwargs):
if 'host' in kwargs:
if self.ip_dict.has_key(kwargs['host']):
self.ip_dict[kwargs['host']] += 1
else:
self.ip_dict[kwargs['host']] = 1
self.total_ip += 1
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
# Do more HERE
for log_doc in collection.find(condition):
self.__process_doc(**log_doc)
def report(self, **kwargs):
print '== IP counter =='
print "HTTP IPs: %d" % self.total_ip
for ip in self.ip_dict.keys():
print "%s: %d" % (ip, self.ip_dict[ip])
Add plugin count ip using mongo aggregation framework
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
from bson.code import Code
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.result = {}
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
reducer = Code("""
function(curr,result){
result.count++;
}
""")
host_result = collection.group(
key = {"host":1},
condition = condition,
initial = {"count":0},
reduce = reducer)
self.result[collection.name] = host_result
# mongo shell command
#db.runCommand({group:{ ns:"www_ename_cn_access", key:{host:1}, $reduce:function(curr,result){result.times += 1}, initial:{"times":0}}})
#db.news_ename_cn_access.group({key:{host:1},reduce:function(curr,result){result.times += 1;},initial:{times:0}})
def report(self, **kwargs):
print '== IP counter =='
print self.result
|
<commit_before>#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.total_ip = 0
self.ip_dict = {}
def __process_doc(self, **kwargs):
if 'host' in kwargs:
if self.ip_dict.has_key(kwargs['host']):
self.ip_dict[kwargs['host']] += 1
else:
self.ip_dict[kwargs['host']] = 1
self.total_ip += 1
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
# Do more HERE
for log_doc in collection.find(condition):
self.__process_doc(**log_doc)
def report(self, **kwargs):
print '== IP counter =='
print "HTTP IPs: %d" % self.total_ip
for ip in self.ip_dict.keys():
print "%s: %d" % (ip, self.ip_dict[ip])
<commit_msg>Add plugin count ip using mongo aggregation framework<commit_after>
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
from bson.code import Code
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.result = {}
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
reducer = Code("""
function(curr,result){
result.count++;
}
""")
host_result = collection.group(
key = {"host":1},
condition = condition,
initial = {"count":0},
reduce = reducer)
self.result[collection.name] = host_result
# mongo shell command
#db.runCommand({group:{ ns:"www_ename_cn_access", key:{host:1}, $reduce:function(curr,result){result.times += 1}, initial:{"times":0}}})
#db.news_ename_cn_access.group({key:{host:1},reduce:function(curr,result){result.times += 1;},initial:{times:0}})
def report(self, **kwargs):
print '== IP counter =='
print self.result
|
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.total_ip = 0
self.ip_dict = {}
def __process_doc(self, **kwargs):
if 'host' in kwargs:
if self.ip_dict.has_key(kwargs['host']):
self.ip_dict[kwargs['host']] += 1
else:
self.ip_dict[kwargs['host']] = 1
self.total_ip += 1
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
# Do more HERE
for log_doc in collection.find(condition):
self.__process_doc(**log_doc)
def report(self, **kwargs):
print '== IP counter =='
print "HTTP IPs: %d" % self.total_ip
for ip in self.ip_dict.keys():
print "%s: %d" % (ip, self.ip_dict[ip])
Add plugin count ip using mongo aggregation framework#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
from bson.code import Code
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.result = {}
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
reducer = Code("""
function(curr,result){
result.count++;
}
""")
host_result = collection.group(
key = {"host":1},
condition = condition,
initial = {"count":0},
reduce = reducer)
self.result[collection.name] = host_result
# mongo shell command
#db.runCommand({group:{ ns:"www_ename_cn_access", key:{host:1}, $reduce:function(curr,result){result.times += 1}, initial:{"times":0}}})
#db.news_ename_cn_access.group({key:{host:1},reduce:function(curr,result){result.times += 1;},initial:{times:0}})
def report(self, **kwargs):
print '== IP counter =='
print self.result
|
<commit_before>#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.total_ip = 0
self.ip_dict = {}
def __process_doc(self, **kwargs):
if 'host' in kwargs:
if self.ip_dict.has_key(kwargs['host']):
self.ip_dict[kwargs['host']] += 1
else:
self.ip_dict[kwargs['host']] = 1
self.total_ip += 1
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
# Do more HERE
for log_doc in collection.find(condition):
self.__process_doc(**log_doc)
def report(self, **kwargs):
print '== IP counter =='
print "HTTP IPs: %d" % self.total_ip
for ip in self.ip_dict.keys():
print "%s: %d" % (ip, self.ip_dict[ip])
<commit_msg>Add plugin count ip using mongo aggregation framework<commit_after>#!/usr/bin/env python
# -*- coding:utf-8 -*-
import sys
sys.path.insert(0, "..")
from libs.manager import Plugin
from bson.code import Code
class CountIPNew(Plugin):
def __init__(self, **kwargs):
self.keywords = ['counter', 'ip']
self.result = {}
def process(self, **kwargs):
collection = kwargs['collection']
condition = {}
if 'condition' in kwargs:
condition = kwargs['condition']
reducer = Code("""
function(curr,result){
result.count++;
}
""")
host_result = collection.group(
key = {"host":1},
condition = condition,
initial = {"count":0},
reduce = reducer)
self.result[collection.name] = host_result
# mongo shell command
#db.runCommand({group:{ ns:"www_ename_cn_access", key:{host:1}, $reduce:function(curr,result){result.times += 1}, initial:{"times":0}}})
#db.news_ename_cn_access.group({key:{host:1},reduce:function(curr,result){result.times += 1;},initial:{times:0}})
def report(self, **kwargs):
print '== IP counter =='
print self.result
|
fa1f148b33c61e91044c19a88737abd2ec86c6bf
|
yunity/api/public/auth.py
|
yunity/api/public/auth.py
|
from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.ViewSet):
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
|
from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.GenericViewSet):
serializer_class = AuthLoginSerializer
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
|
Enable easy login through browsable API (discovery through serializer_class)
|
Enable easy login through browsable API (discovery through serializer_class)
|
Python
|
agpl-3.0
|
yunity/yunity-core,yunity/foodsaving-backend,yunity/foodsaving-backend,yunity/foodsaving-backend,yunity/yunity-core
|
from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.ViewSet):
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
Enable easy login through browsable API (discovery through serializer_class)
|
from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.GenericViewSet):
serializer_class = AuthLoginSerializer
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
|
<commit_before>from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.ViewSet):
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
<commit_msg>Enable easy login through browsable API (discovery through serializer_class)<commit_after>
|
from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.GenericViewSet):
serializer_class = AuthLoginSerializer
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
|
from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.ViewSet):
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
Enable easy login through browsable API (discovery through serializer_class)from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.GenericViewSet):
serializer_class = AuthLoginSerializer
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
|
<commit_before>from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.ViewSet):
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
<commit_msg>Enable easy login through browsable API (discovery through serializer_class)<commit_after>from django.contrib.auth import logout
from django.middleware.csrf import get_token as generate_csrf_token_for_frontend
from rest_framework import status, viewsets
from rest_framework.decorators import list_route
from rest_framework.response import Response
from yunity.api.serializers import UserSerializer, AuthLoginSerializer
class AuthViewSet(viewsets.GenericViewSet):
serializer_class = AuthLoginSerializer
@list_route(methods=['get'])
def status(self, request):
""" Get the login state (logged in user)
---
response_serializer: UserSerializer
"""
generate_csrf_token_for_frontend(request)
if request.user.is_anonymous():
serializer = UserSerializer()
else:
serializer = UserSerializer(request.user)
return Response(serializer.data)
def create(self, request, **kwargs):
""" Log in
---
request_serializer: AuthLoginSerializer
response_serializer: UserSerializer
"""
serializer = AuthLoginSerializer(data=request.data, context={'request': request})
if serializer.is_valid():
return Response(data=UserSerializer(request.user).data, status=status.HTTP_201_CREATED)
else:
return Response(data=serializer.errors, status=status.HTTP_400_BAD_REQUEST)
@list_route(methods=['POST'])
def logout(self, request, **kwargs):
logout(request)
return Response(status = status.HTTP_200_OK)
|
4ce8cb1d943c034cf2d0435772864b34588af96d
|
.bin/broadcast_any_song.py
|
.bin/broadcast_any_song.py
|
#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("wget -O - " + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
|
#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("curl -#" + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
|
Use curl instead of wget.
|
Use curl instead of wget.
|
Python
|
mit
|
ryanmjacobs/ryans_dotfiles,ryanmjacobs/ryans_dotfiles
|
#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("wget -O - " + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
Use curl instead of wget.
|
#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("curl -#" + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
|
<commit_before>#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("wget -O - " + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
<commit_msg>Use curl instead of wget.<commit_after>
|
#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("curl -#" + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
|
#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("wget -O - " + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
Use curl instead of wget.#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("curl -#" + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
|
<commit_before>#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("wget -O - " + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
<commit_msg>Use curl instead of wget.<commit_after>#!/usr/bin/env python2
################################################################################
# broadcast_any_song.py
#
# Uses the Exfm REST API to broadcast a song, (basically scours Tumblr for an
# audio file matching a query then sends it to PiFM.)
#
# Maintained By: Ryan Jacobs <[email protected]>
#
# May 18, 2014 -> Creation date.
################################################################################
# Global Variables
NC_HOST="gamma"
NC_PORT=1234
CHANNEL=94.3
import os # to execute shell commands
import sys # arguments
import json # json parsing
import urllib2 # url parsing and downloading
if not len(sys.argv) > 1:
print('Usage: ' + sys.argv[0] + ' <search term>')
exit(1)
json_url = urllib2.urlopen("http://ex.fm/api/v3/song/search/%s"% "+".join(sys.argv[1:]))
parsed_json = json.loads(json_url.read())
song_url = parsed_json["songs"][0]["url"]
os.system("curl -#" + song_url + " | nc " + str(NC_HOST) + " " + str(NC_PORT))
# Reset the terminal to fix the broken state
os.system('reset')
|
bcb58ba1909f82f3ff11cfdfa05bbfaace7f82ec
|
AFQ/__init__.py
|
AFQ/__init__.py
|
from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from ._meta import __version__ # noqa
|
from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from .version import __version__ # noqa
|
Change back this file name to version
|
Change back this file name to version
|
Python
|
bsd-2-clause
|
arokem/pyAFQ,yeatmanlab/pyAFQ,arokem/pyAFQ,yeatmanlab/pyAFQ
|
from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from ._meta import __version__ # noqa
Change back this file name to version
|
from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from .version import __version__ # noqa
|
<commit_before>from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from ._meta import __version__ # noqa
<commit_msg>Change back this file name to version<commit_after>
|
from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from .version import __version__ # noqa
|
from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from ._meta import __version__ # noqa
Change back this file name to versionfrom .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from .version import __version__ # noqa
|
<commit_before>from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from ._meta import __version__ # noqa
<commit_msg>Change back this file name to version<commit_after>from .api import * # noqa
from .data import * # noqa
from .utils import * # noqa
from .version import __version__ # noqa
|
511e92e796224d8185a820d88d12d52c5479b739
|
pomodoro_calculator/main.py
|
pomodoro_calculator/main.py
|
"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each pomodori [default: 5].
-l, --long-break=<minutes> the amount of mintues between every five pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
|
"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available Pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each Pomodori [default: 5].
-l, --long-break=<minutes> the amount of minutes between every four Pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
|
Fix command line usage options
|
Fix command line usage options
|
Python
|
mit
|
Matt-Deacalion/Pomodoro-Calculator
|
"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each pomodori [default: 5].
-l, --long-break=<minutes> the amount of mintues between every five pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
Fix command line usage options
|
"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available Pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each Pomodori [default: 5].
-l, --long-break=<minutes> the amount of minutes between every four Pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
|
<commit_before>"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each pomodori [default: 5].
-l, --long-break=<minutes> the amount of mintues between every five pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
<commit_msg>Fix command line usage options<commit_after>
|
"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available Pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each Pomodori [default: 5].
-l, --long-break=<minutes> the amount of minutes between every four Pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
|
"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each pomodori [default: 5].
-l, --long-break=<minutes> the amount of mintues between every five pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
Fix command line usage options"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available Pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each Pomodori [default: 5].
-l, --long-break=<minutes> the amount of minutes between every four Pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
|
<commit_before>"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each pomodori [default: 5].
-l, --long-break=<minutes> the amount of mintues between every five pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
<commit_msg>Fix command line usage options<commit_after>"""Calculate the number of Pomodori available within a time period.
Usage:
get-pomodori [--from=<time>] [--break=<minutes>] [--long-break=<minutes>] <end-time>
get-pomodori (-h | --help | --version)
Options:
--version show program's version number and exit.
-h, --help show this help message and exit.
-f, --from=<time> calculate available Pomodori from this time [default: now].
-b, --break=<minutes> the amount of minutes between each Pomodori [default: 5].
-l, --long-break=<minutes> the amount of minutes between every four Pomodori [default: 15].
"""
from docopt import docopt
def main():
docopt(__doc__, version='0.2')
if __name__ == '__main__':
main()
|
e49e7484987e3b508802adbd9e05b2b156eb6bdd
|
manage.py
|
manage.py
|
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()
|
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary, Word
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()
|
Add Word model to shell context
|
Add Word model to shell context
|
Python
|
mit
|
Encrylize/MyDictionary,Encrylize/MyDictionary,Encrylize/MyDictionary
|
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()Add Word model to shell context
|
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary, Word
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()
|
<commit_before>import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()<commit_msg>Add Word model to shell context<commit_after>
|
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary, Word
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()
|
import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()Add Word model to shell contextimport os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary, Word
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()
|
<commit_before>import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()<commit_msg>Add Word model to shell context<commit_after>import os
import coverage
from flask_script import Manager, Shell
from flask_migrate import Migrate, MigrateCommand
from config import basedir
from app import create_app, db
from app.models import User, Dictionary, Word
app = create_app(os.getenv("MYDICTIONARY_CONFIG") or "default")
migrate = Migrate(app, db)
manager = Manager(app)
def make_shell_context():
return dict(app=app, db=db, User=User, Dictionary=Dictionary, Word=Word)
manager.add_command("shell", Shell(make_context=make_shell_context))
manager.add_command("db", MigrateCommand)
cov = coverage.coverage(branch=True, include="app/*")
@manager.command
def test(coverage=False):
""" Run the unit tests. """
if coverage:
cov.start()
import unittest
tests = unittest.TestLoader().discover("tests")
unittest.TextTestRunner(verbosity=2).run(tests)
if coverage:
cov.stop()
cov.save()
print("Coverage Summary:")
cov.report()
cov_dir = os.path.join(basedir, "tmp/coverage")
cov.html_report(directory=cov_dir)
print("HTML version: %s/index.html" % cov_dir)
cov.erase()
if __name__ == "__main__":
manager.run()
|
d883a0fd09a42ff84ebb2ccf331692167370444b
|
ESLog/esloghandler.py
|
ESLog/esloghandler.py
|
# -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
self.url = urllib.parse.urlparse(url)
print(self.url)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
|
# -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
# Parse the url
self.url = urllib.parse.urlparse(url)
# If no scheme is given, set it to http
if not self.url.scheme:
self.url.scheme = "http"
# If a scheme is given but it is not http, raise an exception
elif self.url.scheme != "http":
raise ValueError("Only HTTP is supported.")
# If no port is given default to 9200
if not self.url.port:
self.url.port = "9200"
# If no path is given or it is only a / use thi index and doc_type to construct one.
if not self.url.path or self.url.path == "/":
# an index is mandatory for Elasticsearch, doc_type too but it defaults to log
if not index:
raise ValueError("Elasticsearch index cannot be ommitted.")
else:
self.url.path = os.path.join("/", index, doc_type)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
|
Revert "trying to simplefy __init__"
|
Revert "trying to simplefy __init__"
This reverts commit f2e3887bcd53b1c35af2d9dfe2363ea9e2a407f5.
|
Python
|
mit
|
Rio/ESLog
|
# -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
self.url = urllib.parse.urlparse(url)
print(self.url)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
Revert "trying to simplefy __init__"
This reverts commit f2e3887bcd53b1c35af2d9dfe2363ea9e2a407f5.
|
# -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
# Parse the url
self.url = urllib.parse.urlparse(url)
# If no scheme is given, set it to http
if not self.url.scheme:
self.url.scheme = "http"
# If a scheme is given but it is not http, raise an exception
elif self.url.scheme != "http":
raise ValueError("Only HTTP is supported.")
# If no port is given default to 9200
if not self.url.port:
self.url.port = "9200"
# If no path is given or it is only a / use thi index and doc_type to construct one.
if not self.url.path or self.url.path == "/":
# an index is mandatory for Elasticsearch, doc_type too but it defaults to log
if not index:
raise ValueError("Elasticsearch index cannot be ommitted.")
else:
self.url.path = os.path.join("/", index, doc_type)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
|
<commit_before># -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
self.url = urllib.parse.urlparse(url)
print(self.url)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
<commit_msg>Revert "trying to simplefy __init__"
This reverts commit f2e3887bcd53b1c35af2d9dfe2363ea9e2a407f5.<commit_after>
|
# -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
# Parse the url
self.url = urllib.parse.urlparse(url)
# If no scheme is given, set it to http
if not self.url.scheme:
self.url.scheme = "http"
# If a scheme is given but it is not http, raise an exception
elif self.url.scheme != "http":
raise ValueError("Only HTTP is supported.")
# If no port is given default to 9200
if not self.url.port:
self.url.port = "9200"
# If no path is given or it is only a / use thi index and doc_type to construct one.
if not self.url.path or self.url.path == "/":
# an index is mandatory for Elasticsearch, doc_type too but it defaults to log
if not index:
raise ValueError("Elasticsearch index cannot be ommitted.")
else:
self.url.path = os.path.join("/", index, doc_type)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
|
# -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
self.url = urllib.parse.urlparse(url)
print(self.url)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
Revert "trying to simplefy __init__"
This reverts commit f2e3887bcd53b1c35af2d9dfe2363ea9e2a407f5.# -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
# Parse the url
self.url = urllib.parse.urlparse(url)
# If no scheme is given, set it to http
if not self.url.scheme:
self.url.scheme = "http"
# If a scheme is given but it is not http, raise an exception
elif self.url.scheme != "http":
raise ValueError("Only HTTP is supported.")
# If no port is given default to 9200
if not self.url.port:
self.url.port = "9200"
# If no path is given or it is only a / use thi index and doc_type to construct one.
if not self.url.path or self.url.path == "/":
# an index is mandatory for Elasticsearch, doc_type too but it defaults to log
if not index:
raise ValueError("Elasticsearch index cannot be ommitted.")
else:
self.url.path = os.path.join("/", index, doc_type)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
|
<commit_before># -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
self.url = urllib.parse.urlparse(url)
print(self.url)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
<commit_msg>Revert "trying to simplefy __init__"
This reverts commit f2e3887bcd53b1c35af2d9dfe2363ea9e2a407f5.<commit_after># -*- coding: utf-8 -*-
from datetime import datetime
import logging
import os
import json
import urllib.request
import urllib.parse
class ESLogHandler(logging.Handler):
def __init__(self, url, index=None, doc_type="log", level=logging.NOTSET):
logging.Handler.__init__(self, level=level)
# Parse the url
self.url = urllib.parse.urlparse(url)
# If no scheme is given, set it to http
if not self.url.scheme:
self.url.scheme = "http"
# If a scheme is given but it is not http, raise an exception
elif self.url.scheme != "http":
raise ValueError("Only HTTP is supported.")
# If no port is given default to 9200
if not self.url.port:
self.url.port = "9200"
# If no path is given or it is only a / use thi index and doc_type to construct one.
if not self.url.path or self.url.path == "/":
# an index is mandatory for Elasticsearch, doc_type too but it defaults to log
if not index:
raise ValueError("Elasticsearch index cannot be ommitted.")
else:
self.url.path = os.path.join("/", index, doc_type)
# end __init__
def emit(self, record):
# Break the record down to a dictionary
message = dict()
message["timestamp"] = datetime.now().isoformat()
message["level"] = record.levelname
message["name"] = record.name
message["lineno"] = record.lineno
message["message"] = record.msg
json_message = json.dumps(message)
json_message_bytes = json_message.encode("utf8")
urllib.request.urlopen(self.url, data=json_message_bytes)
# end emit
# end ESLogHandler
|
ad8cdf0ed4f2b6f3e2586dc5c6dd0f922a556972
|
ExpandRegion.py
|
ExpandRegion.py
|
import sublime_plugin
from basic_expansions import foo
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
foo();
|
import sublime, sublime_plugin, re
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
region = self.view.sel()[0]
string = self.view.substr(sublime.Region(0, self.view.size()))
start = region.begin()
end = region.end()
if self.expand_to_word(string, start, end) is None:
print "none"
def expand_to_word(self, string, startIndex, endIndex):
wordRe = re.compile("^[a-zA-Z0-9_]*$");
search = True;
searchIndex = startIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newStartIndex = searchIndex + 1
search = False
else:
searchIndex -= 1
search = True;
searchIndex = endIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newEndIndex = searchIndex
search = False
else:
searchIndex += 1
if startIndex == newStartIndex and endIndex == newEndIndex:
return None
else:
self.view.sel().add(sublime.Region(newStartIndex, newEndIndex))
return True
|
Add expand selection to word
|
Add expand selection to word
|
Python
|
mit
|
aronwoost/sublime-expand-region,johyphenel/sublime-expand-region,johyphenel/sublime-expand-region
|
import sublime_plugin
from basic_expansions import foo
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
foo();Add expand selection to word
|
import sublime, sublime_plugin, re
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
region = self.view.sel()[0]
string = self.view.substr(sublime.Region(0, self.view.size()))
start = region.begin()
end = region.end()
if self.expand_to_word(string, start, end) is None:
print "none"
def expand_to_word(self, string, startIndex, endIndex):
wordRe = re.compile("^[a-zA-Z0-9_]*$");
search = True;
searchIndex = startIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newStartIndex = searchIndex + 1
search = False
else:
searchIndex -= 1
search = True;
searchIndex = endIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newEndIndex = searchIndex
search = False
else:
searchIndex += 1
if startIndex == newStartIndex and endIndex == newEndIndex:
return None
else:
self.view.sel().add(sublime.Region(newStartIndex, newEndIndex))
return True
|
<commit_before>import sublime_plugin
from basic_expansions import foo
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
foo();<commit_msg>Add expand selection to word<commit_after>
|
import sublime, sublime_plugin, re
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
region = self.view.sel()[0]
string = self.view.substr(sublime.Region(0, self.view.size()))
start = region.begin()
end = region.end()
if self.expand_to_word(string, start, end) is None:
print "none"
def expand_to_word(self, string, startIndex, endIndex):
wordRe = re.compile("^[a-zA-Z0-9_]*$");
search = True;
searchIndex = startIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newStartIndex = searchIndex + 1
search = False
else:
searchIndex -= 1
search = True;
searchIndex = endIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newEndIndex = searchIndex
search = False
else:
searchIndex += 1
if startIndex == newStartIndex and endIndex == newEndIndex:
return None
else:
self.view.sel().add(sublime.Region(newStartIndex, newEndIndex))
return True
|
import sublime_plugin
from basic_expansions import foo
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
foo();Add expand selection to wordimport sublime, sublime_plugin, re
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
region = self.view.sel()[0]
string = self.view.substr(sublime.Region(0, self.view.size()))
start = region.begin()
end = region.end()
if self.expand_to_word(string, start, end) is None:
print "none"
def expand_to_word(self, string, startIndex, endIndex):
wordRe = re.compile("^[a-zA-Z0-9_]*$");
search = True;
searchIndex = startIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newStartIndex = searchIndex + 1
search = False
else:
searchIndex -= 1
search = True;
searchIndex = endIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newEndIndex = searchIndex
search = False
else:
searchIndex += 1
if startIndex == newStartIndex and endIndex == newEndIndex:
return None
else:
self.view.sel().add(sublime.Region(newStartIndex, newEndIndex))
return True
|
<commit_before>import sublime_plugin
from basic_expansions import foo
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
foo();<commit_msg>Add expand selection to word<commit_after>import sublime, sublime_plugin, re
class ExpandRegionCommand(sublime_plugin.TextCommand):
def run(self, edit):
region = self.view.sel()[0]
string = self.view.substr(sublime.Region(0, self.view.size()))
start = region.begin()
end = region.end()
if self.expand_to_word(string, start, end) is None:
print "none"
def expand_to_word(self, string, startIndex, endIndex):
wordRe = re.compile("^[a-zA-Z0-9_]*$");
search = True;
searchIndex = startIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newStartIndex = searchIndex + 1
search = False
else:
searchIndex -= 1
search = True;
searchIndex = endIndex;
while search:
char = string[searchIndex:searchIndex+1]
if wordRe.match(char) is None:
newEndIndex = searchIndex
search = False
else:
searchIndex += 1
if startIndex == newStartIndex and endIndex == newEndIndex:
return None
else:
self.view.sel().add(sublime.Region(newStartIndex, newEndIndex))
return True
|
3e45f7d71fbd154a1039836228098efb62457f1b
|
tests/app/dvla_organisation/test_rest.py
|
tests/app/dvla_organisation/test_rest.py
|
from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}
|
from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations['001'] == 'HM Government'
assert dvla_organisations['500'] == 'Land Registry'
|
Refactor test so that it does not have to change every time we add a new organisation.
|
Refactor test so that it does not have to change every time we add a new organisation.
|
Python
|
mit
|
alphagov/notifications-api,alphagov/notifications-api
|
from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}
Refactor test so that it does not have to change every time we add a new organisation.
|
from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations['001'] == 'HM Government'
assert dvla_organisations['500'] == 'Land Registry'
|
<commit_before>from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}
<commit_msg>Refactor test so that it does not have to change every time we add a new organisation.<commit_after>
|
from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations['001'] == 'HM Government'
assert dvla_organisations['500'] == 'Land Registry'
|
from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}
Refactor test so that it does not have to change every time we add a new organisation.from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations['001'] == 'HM Government'
assert dvla_organisations['500'] == 'Land Registry'
|
<commit_before>from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations == {'001': 'HM Government', '500': 'Land Registry'}
<commit_msg>Refactor test so that it does not have to change every time we add a new organisation.<commit_after>from flask import json
from tests import create_authorization_header
def test_get_dvla_organisations(client):
auth_header = create_authorization_header()
response = client.get('/dvla_organisations', headers=[auth_header])
assert response.status_code == 200
dvla_organisations = json.loads(response.get_data(as_text=True))
assert dvla_organisations['001'] == 'HM Government'
assert dvla_organisations['500'] == 'Land Registry'
|
e3c840567fae974b2a1f169b05b86de97b60c8d0
|
gitcms/publications/urls.py
|
gitcms/publications/urls.py
|
from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings._BASE_DIR + '/../media/publications/files'}),
)
|
from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT + '/publications/files'}),
)
|
Remove stay mention to BASE_URL
|
Remove stay mention to BASE_URL
|
Python
|
agpl-3.0
|
luispedro/django-gitcms,luispedro/django-gitcms
|
from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings._BASE_DIR + '/../media/publications/files'}),
)
Remove stay mention to BASE_URL
|
from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT + '/publications/files'}),
)
|
<commit_before>from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings._BASE_DIR + '/../media/publications/files'}),
)
<commit_msg>Remove stay mention to BASE_URL<commit_after>
|
from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT + '/publications/files'}),
)
|
from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings._BASE_DIR + '/../media/publications/files'}),
)
Remove stay mention to BASE_URLfrom django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT + '/publications/files'}),
)
|
<commit_before>from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings._BASE_DIR + '/../media/publications/files'}),
)
<commit_msg>Remove stay mention to BASE_URL<commit_after>from django.conf.urls.defaults import *
import settings
import views
urlpatterns = patterns('',
(r'^papers/(?P<paper>.+)$', views.papers),
(r'^publications/?$', views.publications, { 'collection' : 'luispedro' }),
(r'^publications/(?P<collection>.+)$', views.publications),
(r'^publications/files/(?P<file>.+)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT + '/publications/files'}),
)
|
99906c1d0db30454f1d3c12d2076abe05939ab0d
|
redash/cli/organization.py
|
redash/cli/organization.py
|
from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
|
from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
@manager.command
def list():
"""List all organizations"""
orgs = models.Organization.select()
for i, org in enumerate(orgs):
if i > 0:
print "-" * 20
print "Id: {}\nName: {}\nSlug: {}".format(org.id, org.name, org.slug)
|
Add 'manage.py org list' command
|
Add 'manage.py org list' command
'org list' simply prints out the organizations.
|
Python
|
bsd-2-clause
|
getredash/redash,easytaxibr/redash,EverlyWell/redash,ninneko/redash,alexanderlz/redash,chriszs/redash,imsally/redash,stefanseifert/redash,easytaxibr/redash,vishesh92/redash,crowdworks/redash,guaguadev/redash,vishesh92/redash,stefanseifert/redash,denisov-vlad/redash,denisov-vlad/redash,rockwotj/redash,hudl/redash,hudl/redash,rockwotj/redash,getredash/redash,denisov-vlad/redash,useabode/redash,guaguadev/redash,akariv/redash,vishesh92/redash,rockwotj/redash,EverlyWell/redash,getredash/redash,useabode/redash,stefanseifert/redash,EverlyWell/redash,ninneko/redash,alexanderlz/redash,44px/redash,denisov-vlad/redash,alexanderlz/redash,44px/redash,hudl/redash,ninneko/redash,guaguadev/redash,crowdworks/redash,amino-data/redash,hudl/redash,moritz9/redash,crowdworks/redash,imsally/redash,guaguadev/redash,crowdworks/redash,moritz9/redash,akariv/redash,44px/redash,moritz9/redash,ninneko/redash,akariv/redash,akariv/redash,amino-data/redash,vishesh92/redash,ninneko/redash,useabode/redash,getredash/redash,easytaxibr/redash,useabode/redash,imsally/redash,akariv/redash,denisov-vlad/redash,getredash/redash,easytaxibr/redash,M32Media/redash,M32Media/redash,guaguadev/redash,chriszs/redash,rockwotj/redash,44px/redash,alexanderlz/redash,chriszs/redash,stefanseifert/redash,imsally/redash,M32Media/redash,amino-data/redash,chriszs/redash,EverlyWell/redash,M32Media/redash,easytaxibr/redash,stefanseifert/redash,amino-data/redash,moritz9/redash
|
from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
Add 'manage.py org list' command
'org list' simply prints out the organizations.
|
from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
@manager.command
def list():
"""List all organizations"""
orgs = models.Organization.select()
for i, org in enumerate(orgs):
if i > 0:
print "-" * 20
print "Id: {}\nName: {}\nSlug: {}".format(org.id, org.name, org.slug)
|
<commit_before>from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
<commit_msg>Add 'manage.py org list' command
'org list' simply prints out the organizations.<commit_after>
|
from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
@manager.command
def list():
"""List all organizations"""
orgs = models.Organization.select()
for i, org in enumerate(orgs):
if i > 0:
print "-" * 20
print "Id: {}\nName: {}\nSlug: {}".format(org.id, org.name, org.slug)
|
from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
Add 'manage.py org list' command
'org list' simply prints out the organizations.from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
@manager.command
def list():
"""List all organizations"""
orgs = models.Organization.select()
for i, org in enumerate(orgs):
if i > 0:
print "-" * 20
print "Id: {}\nName: {}\nSlug: {}".format(org.id, org.name, org.slug)
|
<commit_before>from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
<commit_msg>Add 'manage.py org list' command
'org list' simply prints out the organizations.<commit_after>from flask_script import Manager
from redash import models
manager = Manager(help="Organization management commands.")
@manager.option('domains', help="comma separated list of domains to allow")
def set_google_apps_domains(domains):
organization = models.Organization.select().first()
organization.settings[models.Organization.SETTING_GOOGLE_APPS_DOMAINS] = domains.split(',')
organization.save()
print "Updated list of allowed domains to: {}".format(organization.google_apps_domains)
@manager.command
def show_google_apps_domains():
organization = models.Organization.select().first()
print "Current list of Google Apps domains: {}".format(organization.google_apps_domains)
@manager.command
def list():
"""List all organizations"""
orgs = models.Organization.select()
for i, org in enumerate(orgs):
if i > 0:
print "-" * 20
print "Id: {}\nName: {}\nSlug: {}".format(org.id, org.name, org.slug)
|
0037017e5d496127df10385ef5cd28fd0149aa76
|
account_payment_include_draft_move/__openerp__.py
|
account_payment_include_draft_move/__openerp__.py
|
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"maintainer": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
|
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
|
Move maintainer key out of the manifest
|
[IMP] Move maintainer key out of the manifest
|
Python
|
agpl-3.0
|
ndtran/bank-payment,syci/bank-payment,sergio-incaser/bank-payment,Antiun/bank-payment,syci/bank-payment,hbrunn/bank-payment,diagramsoftware/bank-payment,CompassionCH/bank-payment,damdam-s/bank-payment,sergio-teruel/bank-payment,CompassionCH/bank-payment,Antiun/bank-payment,David-Amaro/bank-payment,sergiocorato/bank-payment,sergiocorato/bank-payment,sergio-incaser/bank-payment,rlizana/bank-payment,open-synergy/bank-payment,rlizana/bank-payment,damdam-s/bank-payment,David-Amaro/bank-payment,incaser/bank-payment,ndtran/bank-payment,sergio-teruel/bank-payment,acsone/bank-payment
|
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"maintainer": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
[IMP] Move maintainer key out of the manifest
|
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
|
<commit_before># -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"maintainer": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
<commit_msg>[IMP] Move maintainer key out of the manifest<commit_after>
|
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
|
# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"maintainer": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
[IMP] Move maintainer key out of the manifest# -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
|
<commit_before># -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"maintainer": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
<commit_msg>[IMP] Move maintainer key out of the manifest<commit_after># -*- coding: utf-8 -*-
#
##############################################################################
#
# Authors: Adrien Peiffer
# Copyright (c) 2014 Acsone SA/NV (http://www.acsone.eu)
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
##############################################################################
{
"name": "Account Payment Draft Move",
"version": "1.0",
"author": "ACSONE SA/NV",
"website": "http://www.acsone.eu",
"images": [],
"category": "Accounting",
"depends": ["account_banking_payment_export"],
"data": [],
"demo": [],
"test": [],
"licence": "AGPL-3",
"installable": True,
"active": False,
}
|
a7fb5345c8f01524dd39dc8286d3cbe2f337f120
|
py/g1/networks/servers/g1/networks/servers/__init__.py
|
py/g1/networks/servers/g1/networks/servers/__init__.py
|
__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
|
__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
# TODO: NOTE: Because we did not set a capacity limit for queue
# (CompletionQueue does not support this feature at the moment),
# this accept loop could possibly spawn an out-of-control number
# of handler tasks.
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
|
Add a TODO explaining why tasks.CompletionQueue needs a capacity limit
|
Add a TODO explaining why tasks.CompletionQueue needs a capacity limit
|
Python
|
mit
|
clchiou/garage,clchiou/garage,clchiou/garage,clchiou/garage
|
__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
Add a TODO explaining why tasks.CompletionQueue needs a capacity limit
|
__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
# TODO: NOTE: Because we did not set a capacity limit for queue
# (CompletionQueue does not support this feature at the moment),
# this accept loop could possibly spawn an out-of-control number
# of handler tasks.
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
|
<commit_before>__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
<commit_msg>Add a TODO explaining why tasks.CompletionQueue needs a capacity limit<commit_after>
|
__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
# TODO: NOTE: Because we did not set a capacity limit for queue
# (CompletionQueue does not support this feature at the moment),
# this accept loop could possibly spawn an out-of-control number
# of handler tasks.
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
|
__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
Add a TODO explaining why tasks.CompletionQueue needs a capacity limit__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
# TODO: NOTE: Because we did not set a capacity limit for queue
# (CompletionQueue does not support this feature at the moment),
# this accept loop could possibly spawn an out-of-control number
# of handler tasks.
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
|
<commit_before>__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
<commit_msg>Add a TODO explaining why tasks.CompletionQueue needs a capacity limit<commit_after>__all__ = [
'SocketServer',
]
import errno
import logging
from g1.asyncs.bases import servers
from g1.asyncs.bases import tasks
LOG = logging.getLogger(__name__)
LOG.addHandler(logging.NullHandler())
class SocketServer:
def __init__(self, socket, handler):
self._socket = socket
self._handler = handler
async def serve(self):
LOG.info('start server: %r', self._socket)
with self._socket:
async with tasks.CompletionQueue() as queue:
await servers.supervise_server(
queue,
(queue.spawn(self._accept(queue)), ),
)
LOG.info('stop server: %r', self._socket)
async def _accept(self, queue):
# TODO: NOTE: Because we did not set a capacity limit for queue
# (CompletionQueue does not support this feature at the moment),
# this accept loop could possibly spawn an out-of-control number
# of handler tasks.
while True:
try:
sock, addr = await self._socket.accept()
except OSError as exc:
if exc.errno == errno.EBADF:
LOG.info('server socket close: %r', self._socket)
break
raise
LOG.debug('serve client: %r', addr)
queue.spawn(self._handler(sock, addr))
def shutdown(self):
self._socket.close()
|
cc85fdf3b44b7a69b8d0406c170d409783687d2d
|
__TEMPLATE__.py
|
__TEMPLATE__.py
|
"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section('SOME MODULE TITLE'):
pass
|
"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section(__doc__):
pass
|
Use Docstring as default title value.
|
Use Docstring as default title value.
|
Python
|
apache-2.0
|
christabor/MoAL,christabor/MoAL,christabor/MoAL,christabor/MoAL,christabor/MoAL
|
"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section('SOME MODULE TITLE'):
pass
Use Docstring as default title value.
|
"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section(__doc__):
pass
|
<commit_before>"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section('SOME MODULE TITLE'):
pass
<commit_msg>Use Docstring as default title value.<commit_after>
|
"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section(__doc__):
pass
|
"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section('SOME MODULE TITLE'):
pass
Use Docstring as default title value."""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section(__doc__):
pass
|
<commit_before>"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section('SOME MODULE TITLE'):
pass
<commit_msg>Use Docstring as default title value.<commit_after>"""Module docstring. This talks about the module."""
# -*- coding: utf-8 -*-
__author__ = """Chris Tabor ([email protected])"""
IS_MAIN = True if __name__ == '__main__' else False
if IS_MAIN:
from os import getcwd
from os import sys
sys.path.append(getcwd())
from MOAL.helpers.display import Section
class MyClass(object):
"""Class docstring."""
raise NotImplementedError
if IS_MAIN:
with Section(__doc__):
pass
|
58d11644b08a91ab1e71f697741197f1b697d817
|
tests/request/test_request_header.py
|
tests/request/test_request_header.py
|
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
pass
def test_request_without_headers():
pass
def test_invalid_header_syntax():
pass
|
from httoop import Headers, InvalidHeader
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
h = Headers()
h.parse('Foo: bar\r\n baz')
h.parse('Foo2: bar\r\n\tbaz')
h.parse('Foo3: bar\r\n baz')
h.parse('Foo4: bar\r\n\t baz')
assert h['Foo'] == 'barbaz'
assert h['Foo2'] == 'barbaz'
assert h['Foo3'] == 'bar baz'
assert h['Foo4'] == 'bar baz'
def test_request_without_headers():
pass
def test_invalid_header_syntax():
h = Headers()
invalid_headers = ['Foo']
for char in b"%s\x7F()<>@,;\\\\\"/\[\]?={} \t%s" % (b''.join(map(chr, range(0x00, 0x1F))), ''.join(map(chr, range(0x80, 0xFF)))):
invalid_headers.append(b'Fo%so: bar' % (char,))
for invalid in invalid_headers:
try:
h.parse(invalid)
except InvalidHeader:
pass
else:
assert False, 'Invalid header %r parsed successfully' % (invalid,)
|
Add test case for invalid headers and continuation lines
|
Add test case for invalid headers and continuation lines
|
Python
|
mit
|
spaceone/httoop,spaceone/httoop,spaceone/httoop
|
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
pass
def test_request_without_headers():
pass
def test_invalid_header_syntax():
pass
Add test case for invalid headers and continuation lines
|
from httoop import Headers, InvalidHeader
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
h = Headers()
h.parse('Foo: bar\r\n baz')
h.parse('Foo2: bar\r\n\tbaz')
h.parse('Foo3: bar\r\n baz')
h.parse('Foo4: bar\r\n\t baz')
assert h['Foo'] == 'barbaz'
assert h['Foo2'] == 'barbaz'
assert h['Foo3'] == 'bar baz'
assert h['Foo4'] == 'bar baz'
def test_request_without_headers():
pass
def test_invalid_header_syntax():
h = Headers()
invalid_headers = ['Foo']
for char in b"%s\x7F()<>@,;\\\\\"/\[\]?={} \t%s" % (b''.join(map(chr, range(0x00, 0x1F))), ''.join(map(chr, range(0x80, 0xFF)))):
invalid_headers.append(b'Fo%so: bar' % (char,))
for invalid in invalid_headers:
try:
h.parse(invalid)
except InvalidHeader:
pass
else:
assert False, 'Invalid header %r parsed successfully' % (invalid,)
|
<commit_before>def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
pass
def test_request_without_headers():
pass
def test_invalid_header_syntax():
pass
<commit_msg>Add test case for invalid headers and continuation lines<commit_after>
|
from httoop import Headers, InvalidHeader
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
h = Headers()
h.parse('Foo: bar\r\n baz')
h.parse('Foo2: bar\r\n\tbaz')
h.parse('Foo3: bar\r\n baz')
h.parse('Foo4: bar\r\n\t baz')
assert h['Foo'] == 'barbaz'
assert h['Foo2'] == 'barbaz'
assert h['Foo3'] == 'bar baz'
assert h['Foo4'] == 'bar baz'
def test_request_without_headers():
pass
def test_invalid_header_syntax():
h = Headers()
invalid_headers = ['Foo']
for char in b"%s\x7F()<>@,;\\\\\"/\[\]?={} \t%s" % (b''.join(map(chr, range(0x00, 0x1F))), ''.join(map(chr, range(0x80, 0xFF)))):
invalid_headers.append(b'Fo%so: bar' % (char,))
for invalid in invalid_headers:
try:
h.parse(invalid)
except InvalidHeader:
pass
else:
assert False, 'Invalid header %r parsed successfully' % (invalid,)
|
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
pass
def test_request_without_headers():
pass
def test_invalid_header_syntax():
pass
Add test case for invalid headers and continuation linesfrom httoop import Headers, InvalidHeader
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
h = Headers()
h.parse('Foo: bar\r\n baz')
h.parse('Foo2: bar\r\n\tbaz')
h.parse('Foo3: bar\r\n baz')
h.parse('Foo4: bar\r\n\t baz')
assert h['Foo'] == 'barbaz'
assert h['Foo2'] == 'barbaz'
assert h['Foo3'] == 'bar baz'
assert h['Foo4'] == 'bar baz'
def test_request_without_headers():
pass
def test_invalid_header_syntax():
h = Headers()
invalid_headers = ['Foo']
for char in b"%s\x7F()<>@,;\\\\\"/\[\]?={} \t%s" % (b''.join(map(chr, range(0x00, 0x1F))), ''.join(map(chr, range(0x80, 0xFF)))):
invalid_headers.append(b'Fo%so: bar' % (char,))
for invalid in invalid_headers:
try:
h.parse(invalid)
except InvalidHeader:
pass
else:
assert False, 'Invalid header %r parsed successfully' % (invalid,)
|
<commit_before>def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
pass
def test_request_without_headers():
pass
def test_invalid_header_syntax():
pass
<commit_msg>Add test case for invalid headers and continuation lines<commit_after>from httoop import Headers, InvalidHeader
def test_multiple_same_headers():
pass
def test_header_case_insensitivity():
pass
def test_header_with_continuation_lines():
h = Headers()
h.parse('Foo: bar\r\n baz')
h.parse('Foo2: bar\r\n\tbaz')
h.parse('Foo3: bar\r\n baz')
h.parse('Foo4: bar\r\n\t baz')
assert h['Foo'] == 'barbaz'
assert h['Foo2'] == 'barbaz'
assert h['Foo3'] == 'bar baz'
assert h['Foo4'] == 'bar baz'
def test_request_without_headers():
pass
def test_invalid_header_syntax():
h = Headers()
invalid_headers = ['Foo']
for char in b"%s\x7F()<>@,;\\\\\"/\[\]?={} \t%s" % (b''.join(map(chr, range(0x00, 0x1F))), ''.join(map(chr, range(0x80, 0xFF)))):
invalid_headers.append(b'Fo%so: bar' % (char,))
for invalid in invalid_headers:
try:
h.parse(invalid)
except InvalidHeader:
pass
else:
assert False, 'Invalid header %r parsed successfully' % (invalid,)
|
c45d872be07fd58981580372a2c32f0b1993c1e2
|
example/user_timeline.py
|
example/user_timeline.py
|
#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.startswith(user + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
|
#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.lower().startswith(user.lower() + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
|
Normalize case in my assertion.
|
Normalize case in my assertion.
|
Python
|
mit
|
praekelt/twitty-twister,dustin/twitty-twister
|
#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.startswith(user + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
Normalize case in my assertion.
|
#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.lower().startswith(user.lower() + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
|
<commit_before>#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.startswith(user + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
<commit_msg>Normalize case in my assertion.<commit_after>
|
#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.lower().startswith(user.lower() + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
|
#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.startswith(user + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
Normalize case in my assertion.#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.lower().startswith(user.lower() + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
|
<commit_before>#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.startswith(user + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
<commit_msg>Normalize case in my assertion.<commit_after>#!/usr/bin/env python
"""
Copyright (c) 2008 Dustin Sallings <[email protected]>
"""
import os
import sys
sys.path.append(os.path.join(sys.path[0], '..', 'lib'))
sys.path.append('lib')
from twisted.internet import reactor, protocol, defer, task
import twitter
fetchCount = 0
@defer.deferredGenerator
def getSome(tw, user):
global fetchCount
fetchCount = 0
def gotEntry(msg):
global fetchCount
fetchCount += 1
assert msg.title.lower().startswith(user.lower() + ": ")
l = len(user)
print msg.title[l+2:]
page = 1
while True:
fetchCount = 0
sys.stderr.write("Fetching page %d\n" % page)
d = tw.user_timeline(gotEntry, user, {'count': '200', 'page': str(page)})
page += 1
wfd = defer.waitForDeferred(d)
yield wfd
wfd.getResult()
if fetchCount == 0:
reactor.stop()
user = None
if len(sys.argv) > 3:
user = sys.argv[3]
tw = twitter.Twitter(sys.argv[1], sys.argv[2])
defer.maybeDeferred(getSome, tw, user)
reactor.run()
|
86e52da3cfe7e230ac935b7aa35dcab4b7b23402
|
web/control/views.py
|
web/control/views.py
|
import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
try:
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid command format', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
|
import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
try:
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid control message format', content_type="plain/text")
else:
return HttpResponse('POST action is expected', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
|
Improve the error handling and error response message.
|
Improve the error handling and error response message.
|
Python
|
mpl-2.0
|
klooer/rvi_backend,klooer/rvi_backend,klooer/rvi_backend,klooer/rvi_backend
|
import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
try:
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid command format', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
Improve the error handling and error response message.
|
import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
try:
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid control message format', content_type="plain/text")
else:
return HttpResponse('POST action is expected', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
|
<commit_before>import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
try:
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid command format', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
<commit_msg>Improve the error handling and error response message.<commit_after>
|
import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
try:
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid control message format', content_type="plain/text")
else:
return HttpResponse('POST action is expected', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
|
import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
try:
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid command format', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
Improve the error handling and error response message.import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
try:
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid control message format', content_type="plain/text")
else:
return HttpResponse('POST action is expected', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
|
<commit_before>import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
try:
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid command format', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
<commit_msg>Improve the error handling and error response message.<commit_after>import json
from django.http import HttpResponse
from django.views.decorators.csrf import csrf_exempt
from vehicles.models import Vehicle
import control.tasks
#@api_view(['POST'])
@csrf_exempt
def handle_control(request, vehicle_vin='-1'):
print 'vehicle: ', vehicle_vin
try:
vehicle = Vehicle.objects.filter(veh_vin=vehicle_vin)[0]
if request.method == 'POST':
try:
received_json_data = json.loads(request.body)
print 'received json data', received_json_data
command = received_json_data['command']
print 'command: ', command
try:
control.tasks.handle_control(vehicle, command)
response_data = str(received_json_data)
return HttpResponse(response_data, content_type="application/json")
except Exception as e:
print str(e)
return HttpResponse('Send control command failed', content_type="plain/text")
except:
return HttpResponse('Invalid control message format', content_type="plain/text")
else:
return HttpResponse('POST action is expected', content_type="plain/text")
except:
return HttpResponse('No valid vehicle found.', content_type="plain/text")
|
f6429a3c4b413231ad480f2768d47b78ec0c690b
|
great_expectations/cli/cli_logging.py
|
great_expectations/cli/cli_logging.py
|
import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setLevel(level=logging.WARNING)
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
return module_logger
|
import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
module_logger.setLevel(level=logging.WARNING)
return module_logger
|
Set level on module logger instead
|
Set level on module logger instead
|
Python
|
apache-2.0
|
great-expectations/great_expectations,great-expectations/great_expectations,great-expectations/great_expectations,great-expectations/great_expectations
|
import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setLevel(level=logging.WARNING)
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
return module_loggerSet level on module logger instead
|
import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
module_logger.setLevel(level=logging.WARNING)
return module_logger
|
<commit_before>import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setLevel(level=logging.WARNING)
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
return module_logger<commit_msg>Set level on module logger instead<commit_after>
|
import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
module_logger.setLevel(level=logging.WARNING)
return module_logger
|
import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setLevel(level=logging.WARNING)
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
return module_loggerSet level on module logger insteadimport logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
module_logger.setLevel(level=logging.WARNING)
return module_logger
|
<commit_before>import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setLevel(level=logging.WARNING)
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
return module_logger<commit_msg>Set level on module logger instead<commit_after>import logging
import warnings
warnings.filterwarnings("ignore")
###
# REVIEWER NOTE: THE ORIGINAL IMPLEMENTATION WAS HEAVY HANDED AND I BELIEVE WAS A TEMPORARY WORKAROUND.
# PLEASE CAREFULLY REVIEW TO ENSURE REMOVING THIS DOES NOT AFFECT DESIRED BEHAVIOR
###
logger = logging.getLogger("great_expectations.cli")
def _set_up_logger():
# Log to console with a simple formatter; used by CLI
formatter = logging.Formatter("%(message)s")
handler = logging.StreamHandler()
handler.setFormatter(formatter)
module_logger = logging.getLogger("great_expectations")
module_logger.addHandler(handler)
module_logger.setLevel(level=logging.WARNING)
return module_logger
|
323a92afd125bd97c960ab71c64f78601ec4b000
|
aioinotify/watch.py
|
aioinotify/watch.py
|
import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
|
import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
def __enter__(self):
return self
def __exit__(self, *exc):
self.close()
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
|
Make Watch also a context manager
|
Make Watch also a context manager
|
Python
|
apache-2.0
|
mwfrojdman/aioinotify
|
import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
Make Watch also a context manager
|
import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
def __enter__(self):
return self
def __exit__(self, *exc):
self.close()
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
|
<commit_before>import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
<commit_msg>Make Watch also a context manager<commit_after>
|
import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
def __enter__(self):
return self
def __exit__(self, *exc):
self.close()
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
|
import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
Make Watch also a context managerimport asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
def __enter__(self):
return self
def __exit__(self, *exc):
self.close()
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
|
<commit_before>import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
<commit_msg>Make Watch also a context manager<commit_after>import asyncio
class Watch:
"""Represents an inotify watch as added by InotifyProtocol.watch()"""
def __init__(self, watch_descriptor, callback, protocol):
"""
:param int watch_descriptor: The watch descriptor as returned by inotify_add_watch
:param callback: A function with one positional argument (the event object) called when
an inotify event happens.
"""
self.watch_descriptor = watch_descriptor
self._callback = callback
self._closed = False
self._protocol = protocol
def __enter__(self):
return self
def __exit__(self, *exc):
self.close()
@asyncio.coroutine
def dispatch_event(self, event):
if not self._closed:
yield from self._callback(event)
def close(self):
if not self._closed:
self._protocol._remove_watch(self.watch_descriptor)
self._closed = True
|
2a3d62e4edfd33857feec6fbf20122d2c1a113f8
|
add_labels/label_data.py
|
add_labels/label_data.py
|
import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['cp', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])
|
import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['mv', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])
|
Update label data to point at correct spots
|
Update label data to point at correct spots
|
Python
|
mit
|
matthew-sochor/trail-cam-detector,matthew-sochor/trail-cam-detector
|
import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['cp', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])Update label data to point at correct spots
|
import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['mv', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])
|
<commit_before>import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['cp', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])<commit_msg>Update label data to point at correct spots<commit_after>
|
import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['mv', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])
|
import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['cp', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])Update label data to point at correct spotsimport pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['mv', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])
|
<commit_before>import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['cp', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])<commit_msg>Update label data to point at correct spots<commit_after>import pandas as pd
import subprocess
import sys
import os
source = sys.argv[1]
dest = sys.argv[2]
labels = sys.argv[3]
df = pd.read_csv(labels)
df = df.fillna('EMPTY')
subprocess.call(['mkdir', '-p', dest])
for subjects in list(set(df.Subject)):
subject_list = subjects.split(', ')
for subject in subject_list:
print(dest)
print(subject)
subprocess.call(['mkdir', '-p', os.path.join(dest, subject)])
folders = [file.split('/')[-2] for file in df.SourceFile]
filenames = [file.split('/')[-1] for file in df.SourceFile]
for folder, filename, subjects in zip(folders, filenames, df.Subject):
subject_list = subjects.split(', ')
for subject in subject_list:
subprocess.call(['mv', os.path.join(source, folder, filename), os.path.join(dest, subject, filename)])
|
aa77e74c02ec7276c233454806d55fdb32899a13
|
__init__.py
|
__init__.py
|
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification
from . import visualization
|
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification as vf
from . import visualization as plt
|
Use namespaces plt and vf for visualization and verification modules
|
Use namespaces plt and vf for visualization and verification modules
|
Python
|
bsd-3-clause
|
pySTEPS/pysteps
|
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification
from . import visualization
Use namespaces plt and vf for visualization and verification modules
|
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification as vf
from . import visualization as plt
|
<commit_before>
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification
from . import visualization
<commit_msg>Use namespaces plt and vf for visualization and verification modules<commit_after>
|
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification as vf
from . import visualization as plt
|
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification
from . import visualization
Use namespaces plt and vf for visualization and verification modules
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification as vf
from . import visualization as plt
|
<commit_before>
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification
from . import visualization
<commit_msg>Use namespaces plt and vf for visualization and verification modules<commit_after>
# import subpackages
from . import advection
from . import cascade
from . import io
from . import noise
from . import nowcasts
from . import optflow
from . import postprocessing
from . import timeseries
from . import utils
from . import verification as vf
from . import visualization as plt
|
b1153bc6e8b8b132c146076aeeb6b86ec4f54365
|
__init__.py
|
__init__.py
|
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *
|
bl_info = {
"name": "glTF format",
"author": "Daniel Stokes",
"version": (0, 1, 0),
"blender": (2, 76, 0),
"location": "File > Import-Export",
"description": "Export glTF",
"warning": "",
"wiki_url": ""
"",
"support": 'TESTING',
"category": "Import-Export"}
# Treat as module
if '.' in __name__:
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *
# Treat as addon
else:
if "bpy" in locals():
import importlib
importlib.reload(blendergltf)
import json
import bpy
from bpy.props import (
StringProperty,
)
from bpy_extras.io_utils import (
ExportHelper,
)
from . import blendergltf
class ExportGLTF(bpy.types.Operator, ExportHelper):
"""Save a Khronos glTF File"""
bl_idname = "export_scene.gltf"
bl_label = 'Export glTF'
filename_ext = ".gltf"
filter_glob = StringProperty(
default="*.gltf",
options={'HIDDEN'},
)
check_extension = True
def execute(self, context):
scene = {
'camera': bpy.data.cameras,
'lamps': bpy.data.lamps,
'images': bpy.data.images,
'materials': bpy.data.materials,
'meshes': bpy.data.meshes,
'objects': bpy.data.objects,
'scenes': bpy.data.scenes,
'textures': bpy.data.textures,
}
gltf = blendergltf.export_gltf(scene)
with open(self.filepath, 'w') as fout:
json.dump(gltf, fout, indent=4)
return {'FINISHED'}
def menu_func_export(self, context):
self.layout.operator(ExportGLTF.bl_idname, text="glTF (.gltf)")
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
|
Add experimental support to run module as Blender addon
|
Add experimental support to run module as Blender addon
|
Python
|
apache-2.0
|
Kupoman/blendergltf,lukesanantonio/blendergltf
|
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *Add experimental support to run module as Blender addon
|
bl_info = {
"name": "glTF format",
"author": "Daniel Stokes",
"version": (0, 1, 0),
"blender": (2, 76, 0),
"location": "File > Import-Export",
"description": "Export glTF",
"warning": "",
"wiki_url": ""
"",
"support": 'TESTING',
"category": "Import-Export"}
# Treat as module
if '.' in __name__:
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *
# Treat as addon
else:
if "bpy" in locals():
import importlib
importlib.reload(blendergltf)
import json
import bpy
from bpy.props import (
StringProperty,
)
from bpy_extras.io_utils import (
ExportHelper,
)
from . import blendergltf
class ExportGLTF(bpy.types.Operator, ExportHelper):
"""Save a Khronos glTF File"""
bl_idname = "export_scene.gltf"
bl_label = 'Export glTF'
filename_ext = ".gltf"
filter_glob = StringProperty(
default="*.gltf",
options={'HIDDEN'},
)
check_extension = True
def execute(self, context):
scene = {
'camera': bpy.data.cameras,
'lamps': bpy.data.lamps,
'images': bpy.data.images,
'materials': bpy.data.materials,
'meshes': bpy.data.meshes,
'objects': bpy.data.objects,
'scenes': bpy.data.scenes,
'textures': bpy.data.textures,
}
gltf = blendergltf.export_gltf(scene)
with open(self.filepath, 'w') as fout:
json.dump(gltf, fout, indent=4)
return {'FINISHED'}
def menu_func_export(self, context):
self.layout.operator(ExportGLTF.bl_idname, text="glTF (.gltf)")
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
|
<commit_before>if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *<commit_msg>Add experimental support to run module as Blender addon<commit_after>
|
bl_info = {
"name": "glTF format",
"author": "Daniel Stokes",
"version": (0, 1, 0),
"blender": (2, 76, 0),
"location": "File > Import-Export",
"description": "Export glTF",
"warning": "",
"wiki_url": ""
"",
"support": 'TESTING',
"category": "Import-Export"}
# Treat as module
if '.' in __name__:
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *
# Treat as addon
else:
if "bpy" in locals():
import importlib
importlib.reload(blendergltf)
import json
import bpy
from bpy.props import (
StringProperty,
)
from bpy_extras.io_utils import (
ExportHelper,
)
from . import blendergltf
class ExportGLTF(bpy.types.Operator, ExportHelper):
"""Save a Khronos glTF File"""
bl_idname = "export_scene.gltf"
bl_label = 'Export glTF'
filename_ext = ".gltf"
filter_glob = StringProperty(
default="*.gltf",
options={'HIDDEN'},
)
check_extension = True
def execute(self, context):
scene = {
'camera': bpy.data.cameras,
'lamps': bpy.data.lamps,
'images': bpy.data.images,
'materials': bpy.data.materials,
'meshes': bpy.data.meshes,
'objects': bpy.data.objects,
'scenes': bpy.data.scenes,
'textures': bpy.data.textures,
}
gltf = blendergltf.export_gltf(scene)
with open(self.filepath, 'w') as fout:
json.dump(gltf, fout, indent=4)
return {'FINISHED'}
def menu_func_export(self, context):
self.layout.operator(ExportGLTF.bl_idname, text="glTF (.gltf)")
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
|
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *Add experimental support to run module as Blender addonbl_info = {
"name": "glTF format",
"author": "Daniel Stokes",
"version": (0, 1, 0),
"blender": (2, 76, 0),
"location": "File > Import-Export",
"description": "Export glTF",
"warning": "",
"wiki_url": ""
"",
"support": 'TESTING',
"category": "Import-Export"}
# Treat as module
if '.' in __name__:
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *
# Treat as addon
else:
if "bpy" in locals():
import importlib
importlib.reload(blendergltf)
import json
import bpy
from bpy.props import (
StringProperty,
)
from bpy_extras.io_utils import (
ExportHelper,
)
from . import blendergltf
class ExportGLTF(bpy.types.Operator, ExportHelper):
"""Save a Khronos glTF File"""
bl_idname = "export_scene.gltf"
bl_label = 'Export glTF'
filename_ext = ".gltf"
filter_glob = StringProperty(
default="*.gltf",
options={'HIDDEN'},
)
check_extension = True
def execute(self, context):
scene = {
'camera': bpy.data.cameras,
'lamps': bpy.data.lamps,
'images': bpy.data.images,
'materials': bpy.data.materials,
'meshes': bpy.data.meshes,
'objects': bpy.data.objects,
'scenes': bpy.data.scenes,
'textures': bpy.data.textures,
}
gltf = blendergltf.export_gltf(scene)
with open(self.filepath, 'w') as fout:
json.dump(gltf, fout, indent=4)
return {'FINISHED'}
def menu_func_export(self, context):
self.layout.operator(ExportGLTF.bl_idname, text="glTF (.gltf)")
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
|
<commit_before>if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *<commit_msg>Add experimental support to run module as Blender addon<commit_after>bl_info = {
"name": "glTF format",
"author": "Daniel Stokes",
"version": (0, 1, 0),
"blender": (2, 76, 0),
"location": "File > Import-Export",
"description": "Export glTF",
"warning": "",
"wiki_url": ""
"",
"support": 'TESTING',
"category": "Import-Export"}
# Treat as module
if '.' in __name__:
if 'loaded' in locals():
import imp
imp.reload(blendergltf)
from .blendergltf import *
else:
loaded = True
from .blendergltf import *
# Treat as addon
else:
if "bpy" in locals():
import importlib
importlib.reload(blendergltf)
import json
import bpy
from bpy.props import (
StringProperty,
)
from bpy_extras.io_utils import (
ExportHelper,
)
from . import blendergltf
class ExportGLTF(bpy.types.Operator, ExportHelper):
"""Save a Khronos glTF File"""
bl_idname = "export_scene.gltf"
bl_label = 'Export glTF'
filename_ext = ".gltf"
filter_glob = StringProperty(
default="*.gltf",
options={'HIDDEN'},
)
check_extension = True
def execute(self, context):
scene = {
'camera': bpy.data.cameras,
'lamps': bpy.data.lamps,
'images': bpy.data.images,
'materials': bpy.data.materials,
'meshes': bpy.data.meshes,
'objects': bpy.data.objects,
'scenes': bpy.data.scenes,
'textures': bpy.data.textures,
}
gltf = blendergltf.export_gltf(scene)
with open(self.filepath, 'w') as fout:
json.dump(gltf, fout, indent=4)
return {'FINISHED'}
def menu_func_export(self, context):
self.layout.operator(ExportGLTF.bl_idname, text="glTF (.gltf)")
def register():
bpy.utils.register_module(__name__)
bpy.types.INFO_MT_file_export.append(menu_func_export)
def unregister():
bpy.utils.unregister_module(__name__)
bpy.types.INFO_MT_file_export.remove(menu_func_export)
|
8c81f606499ebadddaf2a362bc8845eb69a21e8d
|
lds-gen.py
|
lds-gen.py
|
#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('};')
|
#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('local:\n *;')
print('};')
|
Stop exporting internal symbols from the shared libraries.
|
Stop exporting internal symbols from the shared libraries.
|
Python
|
bsd-2-clause
|
orthrus/librdkafka,klonikar/librdkafka,klonikar/librdkafka,senior7515/librdkafka,janmejay/librdkafka,senior7515/librdkafka,orthrus/librdkafka,klonikar/librdkafka,janmejay/librdkafka,orthrus/librdkafka,janmejay/librdkafka,senior7515/librdkafka,senior7515/librdkafka,klonikar/librdkafka,orthrus/librdkafka,janmejay/librdkafka
|
#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('};')
Stop exporting internal symbols from the shared libraries.
|
#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('local:\n *;')
print('};')
|
<commit_before>#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('};')
<commit_msg>Stop exporting internal symbols from the shared libraries.<commit_after>
|
#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('local:\n *;')
print('};')
|
#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('};')
Stop exporting internal symbols from the shared libraries.#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('local:\n *;')
print('};')
|
<commit_before>#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('};')
<commit_msg>Stop exporting internal symbols from the shared libraries.<commit_after>#!/usr/bin/env python
#
#
# Generate linker script to only expose symbols of the public API
#
import sys
import re
if __name__ == '__main__':
funcs = list()
last_line = ''
for line in sys.stdin:
m = re.match(r'^(\S+.*\s+\**)?(rd_kafka_\S+)\s*\(', line)
if m:
sym = m.group(2)
m2 = re.match(r'(RD_UNUSED|__attribute__\(\(unused\)\))', line)
if not m2:
funcs.append(sym)
last_line = ''
else:
last_line = line
print('# Automatically generated by lds-gen.py - DO NOT EDIT')
print('{\n global:')
if len(funcs) == 0:
print(' *;')
else:
for f in sorted(funcs):
print(' %s;' % f)
print('local:\n *;')
print('};')
|
b07d74f99338165f8bb83ac0599452b021b96a8f
|
django_boolean_sum.py
|
django_boolean_sum.py
|
from django.conf import settings
from django.db.models.aggregates import Sum
from django.db.models.sql.aggregates import Sum as BaseSQLSum
class SQLSum(BaseSQLSum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
function = None
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
|
from django.conf import settings
from django.db.models.aggregates import Sum
class SQLSum(Sum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
|
Add support for Django 1.10+
|
Add support for Django 1.10+
|
Python
|
bsd-2-clause
|
Mibou/django-boolean-sum
|
from django.conf import settings
from django.db.models.aggregates import Sum
from django.db.models.sql.aggregates import Sum as BaseSQLSum
class SQLSum(BaseSQLSum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
function = None
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
Add support for Django 1.10+
|
from django.conf import settings
from django.db.models.aggregates import Sum
class SQLSum(Sum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
|
<commit_before>from django.conf import settings
from django.db.models.aggregates import Sum
from django.db.models.sql.aggregates import Sum as BaseSQLSum
class SQLSum(BaseSQLSum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
function = None
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
<commit_msg>Add support for Django 1.10+<commit_after>
|
from django.conf import settings
from django.db.models.aggregates import Sum
class SQLSum(Sum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
|
from django.conf import settings
from django.db.models.aggregates import Sum
from django.db.models.sql.aggregates import Sum as BaseSQLSum
class SQLSum(BaseSQLSum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
function = None
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
Add support for Django 1.10+from django.conf import settings
from django.db.models.aggregates import Sum
class SQLSum(Sum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
|
<commit_before>from django.conf import settings
from django.db.models.aggregates import Sum
from django.db.models.sql.aggregates import Sum as BaseSQLSum
class SQLSum(BaseSQLSum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
function = None
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
<commit_msg>Add support for Django 1.10+<commit_after>from django.conf import settings
from django.db.models.aggregates import Sum
class SQLSum(Sum):
@property
def sql_template(self):
if settings.DATABASES['default']['ENGINE'] == \
'django.db.backends.postgresql_psycopg2':
return '%(function)s(%(field)s::int)'
return '%(function)s(%(field)s)'
class BooleanSum(Sum):
def add_to_query(self, query, alias, col, source, is_summary):
aggregate = SQLSum(col, source=source, is_summary=is_summary,
**self.extra)
query.aggregates[alias] = aggregate
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.