commit
stringlengths
40
40
old_file
stringlengths
4
236
new_file
stringlengths
4
236
old_contents
stringlengths
1
3.26k
new_contents
stringlengths
16
4.43k
subject
stringlengths
16
624
message
stringlengths
17
3.29k
lang
stringclasses
5 values
license
stringclasses
13 values
repos
stringlengths
5
91.5k
50ab2ed3d8e50e5106dc486e4d20c889d6b18e82
spkg/base/package_database.py
spkg/base/package_database.py
""" Package database utilities for creating and modifying the database. """ from os.path import split, splitext from json import load f = open("packages.json") data = load(f) g = [] for p in data: pkg = { "name": p["name"], "dependencies": p["dependencies"], "version": p["version"], "download": p["download"], } g.append(pkg) from json import dump from StringIO import StringIO s = StringIO() dump(g, s, sort_keys=True, indent=4) s.seek(0) s = s.read() # Remove the trailing space s = s.replace(" \n", "\n") f = open("packages.json", "w") f.write(s)
""" Package database utilities for creating and modifying the database. """ from os.path import split, splitext from json import load f = open("packages.json") data = load(f) g = [] for p in data: pkg = { "name": p["name"], "dependencies": p["dependencies"], "version": p["version"], "download": p["download"], } g.append(pkg) from json import dump from StringIO import StringIO s = StringIO() dump(g, s, sort_keys=True, indent=4) s.seek(0) s = s.read() # Remove the trailing space s = s.replace(" \n", "\n") f = open("packages.json", "w") f.write(s) f.write("\n")
Add a new line at the end of the file
Add a new line at the end of the file
Python
bsd-3-clause
qsnake/qsnake,qsnake/qsnake
766ea05836544b808cd2c346873d9e4f60c858a1
ping/tests/test_ping.py
ping/tests/test_ping.py
import pytest import mock from datadog_checks.checks import AgentCheck from datadog_checks.ping import PingCheck from datadog_checks.errors import CheckException def mock_exec_ping(): return """FAKEPING 127.0.0.1 (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.093 ms --- 127.0.0.1 ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.093/0.093/0.093/0.000 ms""" def test_check(aggregator, instance): c = PingCheck('ping', {}, {}) # empty instance instance = {} with pytest.raises(CheckException): c.check(instance) # only name with pytest.raises(CheckException): c.check({'name': 'Datadog'}) test_check # good check instance = { 'host': '127.0.0.1', 'name': "Localhost" } with mock.patch.object(c, "_exec_ping", return_value=mock_exec_ping()): c.check(instance) aggregator.assert_service_check('network.ping.can_connect', AgentCheck.OK)
import pytest import mock from datadog_checks.checks import AgentCheck from datadog_checks.ping import PingCheck from datadog_checks.errors import CheckException def mock_exec_ping(): return """FAKEPING 127.0.0.1 (127.0.0.1): 56 data bytes 64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.093 ms --- 127.0.0.1 ping statistics --- 1 packets transmitted, 1 packets received, 0.0% packet loss round-trip min/avg/max/stddev = 0.093/0.093/0.093/0.000 ms""" def test_check(aggregator, instance): c = PingCheck('ping', {}, {}) # empty instance instance = {} with pytest.raises(CheckException): c.check(instance) # only name with pytest.raises(CheckException): c.check({'name': 'Datadog'}) test_check # good check instance = { 'host': '127.0.0.1', 'name': "Localhost" } with mock.patch.object(c, "_exec_ping", return_value=mock_exec_ping()): c.check(instance) aggregator.assert_service_check('network.ping.can_connect', AgentCheck.OK) aggregator.assert_metric('network.ping.can_connect', value=1)
Update test to assert metric
Update test to assert metric
Python
bsd-3-clause
DataDog/integrations-extras,DataDog/integrations-extras,DataDog/integrations-extras,DataDog/integrations-extras,DataDog/integrations-extras
164fe2780554ddca5f66273e11efea37cfaf1368
numba/tests/issues/test_issue_204.py
numba/tests/issues/test_issue_204.py
from numba import autojit, jit @autojit def closure_modulo(a, b): @jit('int32()') def foo(): return a % b return foo() print closure_modulo(100, 48)
from numba import autojit, jit @autojit def closure_modulo(a, b): @jit('int32()') def foo(): return a % b return foo() def test_closure_modulo(): assert closure_modulo(100, 48) == 4 if __name__ == '__main__': test_closure_modulo()
Fix tests for python 3
Fix tests for python 3
Python
bsd-2-clause
GaZ3ll3/numba,pombredanne/numba,ssarangi/numba,stefanseefeld/numba,GaZ3ll3/numba,shiquanwang/numba,jriehl/numba,gdementen/numba,sklam/numba,jriehl/numba,ssarangi/numba,stonebig/numba,sklam/numba,GaZ3ll3/numba,seibert/numba,numba/numba,gmarkall/numba,sklam/numba,GaZ3ll3/numba,gmarkall/numba,stonebig/numba,seibert/numba,seibert/numba,IntelLabs/numba,pombredanne/numba,seibert/numba,numba/numba,jriehl/numba,IntelLabs/numba,shiquanwang/numba,gmarkall/numba,pitrou/numba,IntelLabs/numba,numba/numba,sklam/numba,pombredanne/numba,gdementen/numba,cpcloud/numba,stuartarchibald/numba,GaZ3ll3/numba,IntelLabs/numba,pombredanne/numba,jriehl/numba,pitrou/numba,stonebig/numba,stefanseefeld/numba,stefanseefeld/numba,stuartarchibald/numba,cpcloud/numba,ssarangi/numba,gdementen/numba,gmarkall/numba,cpcloud/numba,stonebig/numba,numba/numba,numba/numba,stefanseefeld/numba,stefanseefeld/numba,stuartarchibald/numba,ssarangi/numba,ssarangi/numba,gdementen/numba,seibert/numba,cpcloud/numba,pitrou/numba,stuartarchibald/numba,jriehl/numba,pombredanne/numba,pitrou/numba,stonebig/numba,IntelLabs/numba,gdementen/numba,stuartarchibald/numba,shiquanwang/numba,pitrou/numba,cpcloud/numba,gmarkall/numba,sklam/numba
25429b016ccd979c95da329491e95e69a4a18308
packages/pcl-reference-assemblies.py
packages/pcl-reference-assemblies.py
import glob import os import shutil class PCLReferenceAssembliesPackage(Package): def __init__(self): Package.__init__(self, name='PortableReferenceAssemblies', version='2014-04-14', sources=['http://storage.bos.xamarin.com/bot-provisioning/PortableReferenceAssemblies-2014-04-14.zip']) def prep(self): self.extract_archive(self.sources[0], validate_only=False, overwrite=True) def build(self): pass # A bunch of shell script written inside python literals ;( def install(self): dest = os.path.join(self.prefix, "lib", "mono", "xbuild-frameworks", ".NETPortable") if not os.path.exists(dest): os.makedirs(dest) shutil.rmtree(dest, ignore_errors=True) pcldir = os.path.join(self.package_build_dir(), self.source_dir_name, ".NETPortable") self.sh("rsync -abv -q %s/* %s" % (pcldir, dest)) PCLReferenceAssembliesPackage()
import glob import os import shutil class PCLReferenceAssembliesPackage(Package): def __init__(self): Package.__init__(self, name='PortableReferenceAssemblies', version='2014-04-14', sources=['http://storage.bos.xamarin.com/bot-provisioning/PortableReferenceAssemblies-2014-04-14.zip']) def prep(self): self.extract_archive(self.sources[0], validate_only=False, overwrite=True) def build(self): pass # A bunch of shell script written inside python literals ;( def install(self): dest = os.path.join(self.prefix, "lib", "mono", "xbuild-frameworks", ".NETPortable") if not os.path.exists(dest): os.makedirs(dest) shutil.rmtree(dest, ignore_errors=True) pcldir = os.path.join(self.package_build_dir(), self.source_dir_name) self.sh("rsync -abv -q %s/* %s" % (pcldir, dest)) PCLReferenceAssembliesPackage()
Fix the directory structure inside the source.
Fix the directory structure inside the source.
Python
mit
mono/bockbuild,BansheeMediaPlayer/bockbuild,BansheeMediaPlayer/bockbuild,BansheeMediaPlayer/bockbuild,mono/bockbuild
b5bf391ca0303f877b39bed4c3266441a9b78b2b
src/waldur_mastermind/common/serializers.py
src/waldur_mastermind/common/serializers.py
from rest_framework import serializers def validate_options(options, attributes): fields = {} for name, option in options.items(): params = {} field_type = option.get('type', '') field_class = serializers.CharField if field_type == 'integer': field_class = serializers.IntegerField elif field_type == 'money': field_class = serializers.IntegerField elif field_type == 'boolean': field_class = serializers.BooleanField default_value = option.get('default') if default_value: params['default'] = default_value else: params['required'] = option.get('required', False) if field_class == serializers.IntegerField: if 'min' in option: params['min_value'] = option.get('min') if 'max' in option: params['max_value'] = option.get('max') if 'choices' in option: field_class = serializers.ChoiceField params['choices'] = option.get('choices') if field_type == 'select_string_multi': field_class = serializers.MultipleChoiceField params['choices'] = option.get('choices') fields[name] = field_class(**params) serializer_class = type('AttributesSerializer', (serializers.Serializer,), fields) serializer = serializer_class(data=attributes) serializer.is_valid(raise_exception=True)
from rest_framework import serializers class StringListSerializer(serializers.ListField): child = serializers.CharField() FIELD_CLASSES = { 'integer': serializers.IntegerField, 'date': serializers.DateField, 'time': serializers.TimeField, 'money': serializers.IntegerField, 'boolean': serializers.BooleanField, 'select_string': serializers.ChoiceField, 'select_string_multi': serializers.MultipleChoiceField, 'select_openstack_tenant': serializers.CharField, 'select_multiple_openstack_tenants': StringListSerializer, 'select_openstack_instance': serializers.CharField, 'select_multiple_openstack_instances': StringListSerializer, } def validate_options(options, attributes): fields = {} for name, option in options.items(): params = {} field_type = option.get('type', '') field_class = FIELD_CLASSES.get(field_type, serializers.CharField) default_value = option.get('default') if default_value: params['default'] = default_value else: params['required'] = option.get('required', False) if field_class == serializers.IntegerField: if 'min' in option: params['min_value'] = option.get('min') if 'max' in option: params['max_value'] = option.get('max') if 'choices' in option: params['choices'] = option['choices'] fields[name] = field_class(**params) serializer_class = type('AttributesSerializer', (serializers.Serializer,), fields) serializer = serializer_class(data=attributes) serializer.is_valid(raise_exception=True)
Fix validation of OpenStack select fields in request-based item form
Fix validation of OpenStack select fields in request-based item form [WAL-4035]
Python
mit
opennode/waldur-mastermind,opennode/waldur-mastermind,opennode/nodeconductor-assembly-waldur,opennode/nodeconductor-assembly-waldur,opennode/waldur-mastermind,opennode/waldur-mastermind,opennode/nodeconductor-assembly-waldur
1fb54fcb5236b8c5f33f3eb855c1085c00eeeb2c
src/__init__.py
src/__init__.py
from .pytesseract import ( # noqa: F401 Output, TesseractError, TesseractNotFoundError, TSVNotSupported, get_tesseract_version, image_to_alto_xml, image_to_boxes, image_to_data, image_to_osd, image_to_pdf_or_hocr, image_to_string, run_and_get_output, )
from .pytesseract import ( # noqa: F401 Output, TesseractError, TesseractNotFoundError, ALTONotSupported, TSVNotSupported, get_tesseract_version, image_to_alto_xml, image_to_boxes, image_to_data, image_to_osd, image_to_pdf_or_hocr, image_to_string, run_and_get_output, )
Make the ALTONotSupported exception available
Make the ALTONotSupported exception available
Python
apache-2.0
madmaze/pytesseract
f89dce3ff6d0858c5a29b96610fe4113d6200184
gallery/storages.py
gallery/storages.py
# coding: utf-8 from __future__ import unicode_literals import re from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.files.storage import FileSystemStorage from django.dispatch import receiver from django.utils.lru_cache import lru_cache from django.utils.module_loading import import_string try: from django.test.signals import setting_changed # Django ≥ 1.8 except ImportError: # pragma: no cover from django.core.signals import setting_changed # Django < 1.8 @lru_cache() def get_storage(name): name = name.upper() storage_setting = 'GALLERY_{}_STORAGE'.format(name) dir_setting = 'GALLERY_{}_DIR'.format(name) try: storage_class = getattr(settings, storage_setting) except AttributeError: # There's a good chance that this fallback will survive for a long # time because deprecating it would require updating all the tests. try: storage_dir = getattr(settings, dir_setting) except AttributeError: raise ImproperlyConfigured( "Please define {} or {}".format(storage_setting, dir_setting)) else: return FileSystemStorage(location=storage_dir) else: return import_string(storage_class)() @receiver(setting_changed) def clear_storages_cache(**kwargs): if re.match(r'^GALLERY_[A-Z]+_(STORAGE|DIR)$', kwargs['setting']): get_storage.cache_clear()
# coding: utf-8 from __future__ import unicode_literals import re from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.core.files.storage import FileSystemStorage from django.dispatch import receiver from django.test.signals import setting_changed from django.utils.lru_cache import lru_cache from django.utils.module_loading import import_string @lru_cache() def get_storage(name): name = name.upper() storage_setting = 'GALLERY_{}_STORAGE'.format(name) dir_setting = 'GALLERY_{}_DIR'.format(name) try: storage_class = getattr(settings, storage_setting) except AttributeError: # There's a good chance that this fallback will survive for a long # time because deprecating it would require updating all the tests. try: storage_dir = getattr(settings, dir_setting) except AttributeError: raise ImproperlyConfigured( "Please define {} or {}".format(storage_setting, dir_setting)) else: return FileSystemStorage(location=storage_dir) else: return import_string(storage_class)() @receiver(setting_changed) def clear_storages_cache(**kwargs): if re.match(r'^GALLERY_[A-Z]+_(STORAGE|DIR)$', kwargs['setting']): get_storage.cache_clear()
Remove backwards compatibility with Django < 1.8.
Remove backwards compatibility with Django < 1.8.
Python
bsd-3-clause
aaugustin/myks-gallery,aaugustin/myks-gallery
4121dc4b67d198b7aeea16a4c46d7fc85e359190
presentation/models.py
presentation/models.py
from django.db import models from model_utils.models import TimeStampedModel from warp.users.models import User class Presentation(TimeStampedModel): subject = models.CharField(max_length=50) author = models.ForeignKey(User, on_delete=models.CASCADE) views = models.IntegerField(default=0) markdown = models.TextField() html = models.TextField()
from django.db import models from model_utils.models import TimeStampedModel from warp.users.models import User class Presentation(TimeStampedModel): subject = models.CharField(max_length=50) author = models.ForeignKey(User, on_delete=models.CASCADE) views = models.IntegerField(default=0) markdown = models.TextField() html = models.TextField() is_public = models.BooleanField(default=True)
Add 'is_public' field for checking the whether or not presentation is public
Add 'is_public' field for checking the whether or not presentation is public
Python
mit
SaturDJang/warp,SaturDJang/warp,SaturDJang/warp,SaturDJang/warp
6c61e1000f3f87501b6e45a2715bd26a3b83b407
collector/absolutefrequency.py
collector/absolutefrequency.py
from collector import ItemCollector class ItemNumericAbsoluteFrequencyCollector(ItemCollector): def __init__(self, previous_collector_set = None): ItemCollector.__init__(self, previous_collector_set) self.absolute_frequencies = {} def collect(self, item, collector_set=None): current_absolute_frequency = self.absolute_frequencies.get(item, 0) + 1 self.absolute_frequencies[item] = current_absolute_frequency def get_result(self, collector_set=None): return self.absolute_frequencies
import collections from collector import ItemCollector class ItemNumericAbsoluteFrequencyCollector(ItemCollector): def __init__(self, previous_collector_set = None): ItemCollector.__init__(self, previous_collector_set) self.absolute_frequencies = collections.defaultdict(int) def collect(self, item, collector_set=None): self.absolute_frequencies[item] += 1 def get_result(self, collector_set=None): return self.absolute_frequencies
Use defaultdict for absolute frequency collector
Use defaultdict for absolute frequency collector
Python
mit
davidfoerster/schema-matching
1318d0bc658d23d22452b27004c5d670f4c80d17
spacy/tests/conftest.py
spacy/tests/conftest.py
import pytest import os import spacy @pytest.fixture(scope="session") def EN(): return spacy.load("en") @pytest.fixture(scope="session") def DE(): return spacy.load("de") def pytest_addoption(parser): parser.addoption("--models", action="store_true", help="include tests that require full models") parser.addoption("--vectors", action="store_true", help="include word vectors tests") parser.addoption("--slow", action="store_true", help="include slow tests") def pytest_runtest_setup(item): for opt in ['models', 'vectors', 'slow']: if opt in item.keywords and not item.config.getoption("--%s" % opt): pytest.skip("need --%s option to run" % opt)
import pytest import os from ..en import English from ..de import German @pytest.fixture(scope="session") def EN(): return English(path=None) @pytest.fixture(scope="session") def DE(): return German(path=None) def pytest_addoption(parser): parser.addoption("--models", action="store_true", help="include tests that require full models") parser.addoption("--vectors", action="store_true", help="include word vectors tests") parser.addoption("--slow", action="store_true", help="include slow tests") def pytest_runtest_setup(item): for opt in ['models', 'vectors', 'slow']: if opt in item.keywords and not item.config.getoption("--%s" % opt): pytest.skip("need --%s option to run" % opt)
Test with the non-loaded versions of the English and German pipelines.
Test with the non-loaded versions of the English and German pipelines.
Python
mit
raphael0202/spaCy,honnibal/spaCy,banglakit/spaCy,aikramer2/spaCy,recognai/spaCy,raphael0202/spaCy,recognai/spaCy,explosion/spaCy,spacy-io/spaCy,explosion/spaCy,oroszgy/spaCy.hu,raphael0202/spaCy,Gregory-Howard/spaCy,aikramer2/spaCy,aikramer2/spaCy,explosion/spaCy,oroszgy/spaCy.hu,aikramer2/spaCy,explosion/spaCy,spacy-io/spaCy,honnibal/spaCy,recognai/spaCy,Gregory-Howard/spaCy,spacy-io/spaCy,Gregory-Howard/spaCy,oroszgy/spaCy.hu,banglakit/spaCy,Gregory-Howard/spaCy,recognai/spaCy,explosion/spaCy,honnibal/spaCy,recognai/spaCy,recognai/spaCy,oroszgy/spaCy.hu,oroszgy/spaCy.hu,banglakit/spaCy,Gregory-Howard/spaCy,spacy-io/spaCy,spacy-io/spaCy,banglakit/spaCy,oroszgy/spaCy.hu,raphael0202/spaCy,raphael0202/spaCy,aikramer2/spaCy,Gregory-Howard/spaCy,raphael0202/spaCy,explosion/spaCy,aikramer2/spaCy,spacy-io/spaCy,banglakit/spaCy,banglakit/spaCy,honnibal/spaCy
07bf035221667bdd80ed8570079163d1162d0dd2
cartoframes/__init__.py
cartoframes/__init__.py
from ._version import __version__ from .core.cartodataframe import CartoDataFrame from .core.logger import set_log_level from .io.carto import read_carto, to_carto, has_table, delete_table, describe_table, \ update_table, copy_table, create_table_from_query __all__ = [ '__version__', 'CartoDataFrame', 'read_carto', 'to_carto', 'has_table', 'delete_table', 'describe_table', 'update_table', 'copy_table', 'create_table_from_query', 'set_log_level' ]
from ._version import __version__ from .utils.utils import check_package from .core.cartodataframe import CartoDataFrame from .core.logger import set_log_level from .io.carto import read_carto, to_carto, has_table, delete_table, describe_table, \ update_table, copy_table, create_table_from_query # Check installed packages versions check_package('carto', '>=1.8.2') check_package('pandas', '>=0.23.0') check_package('geopandas', '>=0.6.0') __all__ = [ '__version__', 'CartoDataFrame', 'read_carto', 'to_carto', 'has_table', 'delete_table', 'describe_table', 'update_table', 'copy_table', 'create_table_from_query', 'set_log_level' ]
Check critical dependencies versions on runtime
Check critical dependencies versions on runtime
Python
bsd-3-clause
CartoDB/cartoframes,CartoDB/cartoframes
f338c4ff0c1ff30a3fa44182b0ce0dcbe4ae9dca
Mariana/regularizations.py
Mariana/regularizations.py
__all__ = ["SingleLayerRegularizer_ABC", "L1", "L2"] class SingleLayerRegularizer_ABC(object) : """An abstract regularization to be applied to a layer.""" def __init__(self, factor, *args, **kwargs) : self.name = self.__class__.__name__ self.factor = factor self.hyperparameters = ["factor"] def getFormula(self, layer) : """Returns the expression to be added to the cost""" raise NotImplemented("Must be implemented in child") class L1(SingleLayerRegularizer_ABC) : """ Will add this to the cost .. math:: factor * abs(Weights) """ def getFormula(self, layer) : return self.factor * ( abs(layer.W).sum() ) class L2(SingleLayerRegularizer_ABC) : """ Will add this to the cost .. math:: factor * (Weights)^2 """ def getFormula(self, layer) : return self.factor * ( abs(layer.W).sum() )
__all__ = ["SingleLayerRegularizer_ABC", "L1", "L2"] class SingleLayerRegularizer_ABC(object) : """An abstract regularization to be applied to a layer.""" def __init__(self, factor, *args, **kwargs) : self.name = self.__class__.__name__ self.factor = factor self.hyperparameters = ["factor"] def getFormula(self, layer) : """Returns the expression to be added to the cost""" raise NotImplemented("Must be implemented in child") class L1(SingleLayerRegularizer_ABC) : """ Will add this to the cost .. math:: factor * abs(Weights) """ def getFormula(self, layer) : return self.factor * ( abs(layer.W).sum() ) class L2(SingleLayerRegularizer_ABC) : """ Will add this to the cost .. math:: factor * (Weights)^2 """ def getFormula(self, layer) : return self.factor * ( (layer.W * layer.W).sum() )
Fix L2 formula that was mistakenly added as L1.
Fix L2 formula that was mistakenly added as L1.
Python
apache-2.0
tariqdaouda/Mariana,tariqdaouda/Mariana,tariqdaouda/Mariana,JonathanSeguin/Mariana
49f61f7f47bbb69236ef319dfa861ea437a0aac4
build_qrc.py
build_qrc.py
#!/usr/bin/env python import os import sys import json def read_conf(fname): if not os.path.isfile(fname): return {} with open(fname, 'r') as conf: return json.load(conf) def build_qrc(resources): yield '<RCC>' yield '<qresource>' for d in resources: for root, dirs, files in os.walk(d): for f in files: yield '<file>{}</file>'.format(os.path.join(root, f)) yield '</qresource>' yield '</RCC>' def build_resources(resources, target): with open(target, 'w') as f: for line in build_qrc(resources): f.write(line + os.linesep) def build(source): conf = read_conf(source) target = os.path.basename(source) if '.' in target: target = target.rsplit('.', 1)[0] target += '.qrc' build_resources(conf.get('resources', []), target) if __name__ == '__main__': build(sys.argv[1] if len(sys.argv) >= 1 else 'resources.json')
#!/usr/bin/env python import os import sys import json def read_conf(fname): if not os.path.isfile(fname): return {} with open(fname, 'r') as conf: return json.load(conf) def build_qrc(resources): yield '<RCC>' yield '<qresource>' for d in resources: for root, dirs, files in os.walk(d): dirs.sort() files.sort() for f in files: yield '<file>{}</file>'.format(os.path.join(root, f)) yield '</qresource>' yield '</RCC>' def build_resources(resources, target): with open(target, 'w') as f: for line in build_qrc(resources): f.write(line + os.linesep) def build(source): conf = read_conf(source) target = os.path.basename(source) if '.' in target: target = target.rsplit('.', 1)[0] target += '.qrc' build_resources(conf.get('resources', []), target) if __name__ == '__main__': build(sys.argv[1] if len(sys.argv) >= 1 else 'resources.json')
Sort qrc input file list
Sort qrc input file list so that yubikey-manager-qt packages build in a reproducible way in spite of indeterministic filesystem readdir order See https://reproducible-builds.org/ for why this is good.
Python
bsd-2-clause
Yubico/yubikey-manager-qt,Yubico/yubikey-manager-qt,Yubico/yubikey-manager-qt,Yubico/yubikey-manager-qt
9209ce05cae66f99166101905f6981da04eef656
wake/filters.py
wake/filters.py
from datetime import datetime from twitter_text import TwitterText def relative_time(timestamp): delta = (datetime.now() - datetime.fromtimestamp(timestamp)) delta_s = delta.days * 86400 + delta.seconds if delta_s < 60: return "less than a minute ago" elif delta_s < 120: return "about a minute ago" elif delta_s < (60 * 60): return str(delta_s / 60) + " minutes ago" elif delta_s < (120 * 60): return "about an hour ago" elif delta_s < (24 * 60 * 60): return "about " + str(delta_s / 3600) + " hours ago" elif delta_s < (48 * 60 * 60): return "1 day ago" else: return str(delta_s / 86400) + " days ago" def tweet(text): return TwitterText(text).autolink.auto_link()
from datetime import datetime from twitter_text import TwitterText from flask import Markup def relative_time(timestamp): delta = (datetime.now() - datetime.fromtimestamp(timestamp)) delta_s = delta.days * 86400 + delta.seconds if delta_s < 60: return "less than a minute ago" elif delta_s < 120: return "about a minute ago" elif delta_s < (60 * 60): return str(delta_s / 60) + " minutes ago" elif delta_s < (120 * 60): return "about an hour ago" elif delta_s < (24 * 60 * 60): return "about " + str(delta_s / 3600) + " hours ago" elif delta_s < (48 * 60 * 60): return "1 day ago" else: return str(delta_s / 86400) + " days ago" def tweet(text): return Markup(TwitterText(text).autolink.auto_link())
Mark output of tweet filter as safe by default
Mark output of tweet filter as safe by default
Python
bsd-3-clause
chromakode/wake
4bc31e675659af54ee26fe5df16a0ee3ebeb5947
firefed/__main__.py
firefed/__main__.py
import argparse import os import re from firefed import Firefed from feature import feature_map, Summary def feature_type(val): try: return feature_map()[val] except KeyError as key: raise argparse.ArgumentTypeError( 'Feature %s not found. Choose from: {%s}' % (key, ', '.join(feature_map()))) def profile_dir(dirname): if dirname is None: dirname = 'default' if os.path.isdir(dirname): return dirname if re.match('^[\\w-]+$', dirname): home = os.path.expanduser('~/.mozilla/firefox') profile_names = os.listdir(home) for name in profile_names: if name.endswith('.%s' % dirname): return os.path.join(home, name) raise argparse.ArgumentTypeError('Profile %s not found.' % dirname) def main(): parser = argparse.ArgumentParser( 'firefed', description= 'Firefed is a Firefox profile analyzer focusing on privacy and security.', ) parser.add_argument( '-p', '--profile', help='profile name or directory', type=profile_dir, required=True) parser.add_argument( '-f', '--feature', type=feature_type, default=Summary, help='{%s}' % ', '.join(feature_map())) parser.add_argument( '-s', '--summarize', action='store_true', help='summarize results') args = parser.parse_args() Firefed(args) if __name__ == '__main__': main()
import argparse import os import re from firefed import Firefed from feature import feature_map, Summary def feature_type(val): try: return feature_map()[val] except KeyError as key: raise argparse.ArgumentTypeError( 'Feature %s not found. Choose from: {%s}' % (key, ', '.join(feature_map()))) def profile_dir(dirname): if dirname is None: dirname = 'default' if os.path.isdir(dirname): return dirname if re.match('^[\\w-]+$', dirname): home = os.path.expanduser('~/.mozilla/firefox') profile_names = os.listdir(home) for name in profile_names: if name.endswith('.%s' % dirname): return os.path.join(home, name) raise argparse.ArgumentTypeError('Profile %s not found.' % dirname) def main(): parser = argparse.ArgumentParser( 'firefed', description= 'Firefed is a Firefox profile analyzer focusing on privacy and security.', ) parser.add_argument( '-p', '--profile', help='profile name or directory', type=profile_dir, default='default') parser.add_argument( '-f', '--feature', type=feature_type, default=Summary, help='{%s}' % ', '.join(feature_map())) parser.add_argument( '-s', '--summarize', action='store_true', help='summarize results') args = parser.parse_args() Firefed(args) if __name__ == '__main__': main()
Add default argument for profile
Add default argument for profile
Python
mit
numirias/firefed
138df31dc628daad0c60f062b05774d6c7d4338d
src/kuas_api/modules/const.py
src/kuas_api/modules/const.py
#-*- coding: utf-8 -*- device_version = { "android": "2.1.2", "android_donate": "2.1.2", "ios": "1.4.3" } # Token duration in seconds token_duration = 3600 # HTTP Status Code ok = 200 no_content = 204
#-*- coding: utf-8 -*- device_version = { "android": "2.1.3", "android_donate": "2.1.2", "ios": "1.6.0" } # Token duration in seconds token_duration = 3600 serect_key = "usapoijupojfa;dsj;lv;ldakjads;lfkjapoiuewqprjf" # HTTP Status Code ok = 200 no_content = 204
Change android version to 2.1.3
Change android version to 2.1.3
Python
mit
JohnSounder/AP-API,kuastw/AP-API,kuastw/AP-API,JohnSounder/AP-API
1d9e9f2b7a2259f19a48ab0e0f41439ba5224648
src/adhocracy/lib/auth/shibboleth.py
src/adhocracy/lib/auth/shibboleth.py
from pylons import config def get_userbadge_mapping(config=config): mapping = config.get('adhocracy.shibboleth.userbadge_mapping', u'') return (line.strip().split(u' ') for line in mapping.strip().split(u'\n') if line is not u'') def _attribute_equals(request, key, value): return request.headers.get(key) == value USERBADGE_MAPPERS = { 'attribute_equals': _attribute_equals, }
from pylons import config def get_userbadge_mapping(config=config): mapping = config.get('adhocracy.shibboleth.userbadge_mapping', u'') return (line.strip().split(u' ') for line in mapping.strip().split(u'\n') if line is not u'') def _attribute_equals(request, key, value): """ exact match """ return request.headers.get(key) == value def _attribute_contains(request, key, value): """ contains element """ elements = (e.strip() for e in request.headers.get(key).split(',')) return value in elements def _attribute_contains_substring(request, key, value): """ contains substring """ return value in request.headers.get(key) USERBADGE_MAPPERS = { 'attribute_equals': _attribute_equals, 'attribute_contains': _attribute_contains, 'attribute_contains_substring': _attribute_contains_substring, }
Add userbade mappings contains and contains_substring
Add userbade mappings contains and contains_substring
Python
agpl-3.0
DanielNeugebauer/adhocracy,DanielNeugebauer/adhocracy,alkadis/vcv,liqd/adhocracy,alkadis/vcv,SysTheron/adhocracy,phihag/adhocracy,alkadis/vcv,DanielNeugebauer/adhocracy,alkadis/vcv,alkadis/vcv,liqd/adhocracy,SysTheron/adhocracy,liqd/adhocracy,phihag/adhocracy,SysTheron/adhocracy,phihag/adhocracy,phihag/adhocracy,liqd/adhocracy,DanielNeugebauer/adhocracy,phihag/adhocracy,DanielNeugebauer/adhocracy
bd6c8b0354e9a32c47593ea19d09789d2a36912f
conanfile.py
conanfile.py
from conans import ConanFile class CtreConan(ConanFile): name = "CTRE" version = "2.0" license = "MIT" url = "https://github.com/hanickadot/compile-time-regular-expressions.git" author = "Hana Dusíková (ctre@hanicka.net)" description = "Compile Time Regular Expression for C++17/20" homepage = "https://github.com/hanickadot/compile-time-regular-expressions" exports = "LICENSE" exports_sources = "include/*" no_copy_source = True def package(self): self.copy("*.hpp") def package_id(self): self.info.header_only()
#!/usr/bin/env python # -*- coding: utf-8 -*- from conans import ConanFile class CtreConan(ConanFile): name = "CTRE" version = "2.0" license = "MIT" url = "https://github.com/hanickadot/compile-time-regular-expressions.git" author = "Hana Dusíková (ctre@hanicka.net)" description = "Compile Time Regular Expression for C++17/20" homepage = "https://github.com/hanickadot/compile-time-regular-expressions" exports = "LICENSE" exports_sources = "include/*" no_copy_source = True def package(self): self.copy("*.hpp") def package_id(self): self.info.header_only()
Use UTF-8 in Conan recipe
Use UTF-8 in Conan recipe - Force python interpreter to use UTF-8 Signed-off-by: Uilian Ries <d4bad57018205bdda203549c36d3feb0bfe416a7@gmail.com>
Python
apache-2.0
hanickadot/compile-time-regular-expressions,hanickadot/compile-time-regular-expressions,hanickadot/compile-time-regular-expressions,hanickadot/syntax-parser
ae424937a7d9341862329cf7f04bd91ccdf345cd
converter.py
converter.py
import json import csv def json_to_csv(json_file): with open(json_file, 'r') as jsonfile, open('output.csv', 'w', newline='') as csvfile: jsn = json.load(jsonfile) fieldnames = [] for name in jsn[0]: fieldnames += [name] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() for elem in jsn: writer.writerow(elem) def csv_to_json(csv_file): with open(csv_file, 'r') as csvfile, open('output.json', 'w') as jsonfile: reader = csv.DictReader(csvfile) jsn = [] for row in reader: jsn += [row] json.dump(jsn, jsonfile) filename = input('Enter filename of CSV file: ') csv_to_json(filename)
import json import csv import argparse def json_to_csv(json_file): with open(json_file, 'r') as jsonfile, open('output.csv', 'w', newline='') as csvfile: jsn = json.load(jsonfile) fieldnames = [] for name in jsn[0]: fieldnames += [name] writer = csv.DictWriter(csvfile, fieldnames=fieldnames) writer.writeheader() for elem in jsn: writer.writerow(elem) def csv_to_json(csv_file): with open(csv_file, 'r') as csvfile, open('output.json', 'w') as jsonfile: reader = csv.DictReader(csvfile) jsn = [] for row in reader: jsn += [row] json.dump(jsn, jsonfile) def main(): parser = argparse.ArgumentParser() parser.add_argument('inputtype', help='The type of input', type=str, choices=['csv', 'json']) parser.add_argument('filename', help='Name of the input file', type=str) args = parser.parse_args() if (args.inputtype=='csv'): csv_to_json(args.filename) outputtype = 'json' elif (args.inputtype=='json'): json_to_csv(args.filename) outputtype = 'csv' print('[*] Output saved as output.{}'.format(outputtype)) if __name__=='__main__': main()
Add command-line arguments and main function
Add command-line arguments and main function
Python
mit
SkullTech/json-csv-converter
6a5413ce81a606476734d9b37b33f683ed0c85e3
cards/card.py
cards/card.py
""" Created on Dec 04, 2016 @author: john papa Copyright 2016 John Papa. All rights reserved. This work is licensed under the MIT License. """ from abc import ABCMeta, abstractproperty class Card(metaclass=ABCMeta): def __init__(self, suit, rank): self._rank = rank self._suit = suit self._value = None def __str__(self): return f"{self._rank} of {self._suit}" @property def rank(self): return self._rank @property def suit(self): return self._suit @abstractproperty def value(self): """ Returns the value of the card used for scoring the game """
""" Created on Dec 04, 2016 @author: john papa Copyright 2016 John Papa. All rights reserved. This work is licensed under the MIT License. """ from abc import ABCMeta, abstractproperty class Card(metaclass=ABCMeta): def __init__(self, suit, rank): self._rank = rank self._suit = suit self._value = None def __str__(self): # return f"{self.rank} of {self.suit}" return "{0} of {1}".format(self.rank, self.suit) @property def rank(self): return self._rank @property def suit(self): return self._suit @abstractproperty def value(self): """ Returns the value of the card used for scoring the game """
Switch to pre-python 3.6 string formatting for Codeship
Switch to pre-python 3.6 string formatting for Codeship
Python
mit
johnpapa2/twenty-one,johnpapa2/twenty-one
58daf6f2225cdf52079072eee47f23a6d188cfa9
resync/resource_set.py
resync/resource_set.py
"""A set of Resource objects used for Capability List Indexes and ResourceSync Description documents. FIXME - what should the ordering be? """ class ResourceSet(dict): """Implementation of class to store resources in Capability List Indexes and ResourceSync Description documents. Key properties of this class are: - has add(resource) method - is iterable and results given in alphanumeric order by resource.uri """ def __iter__(self): """Iterator over all the resources in this resource_list""" self._iter_next_list = sorted(self.keys()) self._iter_next_list.reverse() return(iter(self._iter_next, None)) def _iter_next(self): if (len(self._iter_next_list)>0): return(self[self._iter_next_list.pop()]) else: return(None) def add(self, resource, replace=False): """Add just a single resource""" uri = resource.uri if (uri in self and not replace): raise ResourceSetDupeError("Attempt to add resource already in this set") self[uri]=resource class ResourceSetDupeError(Exception): pass
"""A set of Resource objects used for Capability List Indexes and ResourceSync Description documents. Ordinging is currently alphanumeric (using sorted(..)) on the uri which is the key. """ class ResourceSet(dict): """Implementation of class to store resources in Capability List Indexes and ResourceSync Description documents. Key properties of this class are: - has add(resource) method - is iterable and results given in alphanumeric order by resource.uri """ def __iter__(self): """Iterator over all the resources in this resource_list""" self._iter_next_list = sorted(self.keys()) self._iter_next_list.reverse() return(iter(self._iter_next, None)) def _iter_next(self): if (len(self._iter_next_list)>0): return(self[self._iter_next_list.pop()]) else: return(None) def add(self, resource, replace=False): """Add just a single resource""" uri = resource.uri if (uri in self and not replace): raise ResourceSetDupeError("Attempt to add resource already in this set") self[uri]=resource class ResourceSetDupeError(Exception): pass
Change comment to indicate choice of alphanum order by uri
Change comment to indicate choice of alphanum order by uri
Python
apache-2.0
lindareijnhoudt/resync,resync/resync,lindareijnhoudt/resync,dans-er/resync,dans-er/resync
b6096dbe06f636a462f2c1ff85470599754f613f
app/main/views/sub_navigation_dictionaries.py
app/main/views/sub_navigation_dictionaries.py
def features_nav(): return [ { "name": "Features", "link": "main.features", }, { "name": "Roadmap", "link": "main.roadmap", }, { "name": "Security", "link": "main.security", }, { "name": "Performance", "link": "https://www.gov.uk/performance/govuk-notify", "external_link": True, }, { "name": "Terms of use", "link": "main.terms", }, { "name": "Using Notify", "link": "main.using_notify", }, ]
def features_nav(): return [ { "name": "Features", "link": "main.features", }, { "name": "Roadmap", "link": "main.roadmap", }, { "name": "Security", "link": "main.security", }, { "name": "Terms of use", "link": "main.terms", }, { "name": "Using Notify", "link": "main.using_notify", }, ]
Remove performance link from features nav
Remove performance link from features nav The features nav is supposed to navigate your between pages in the app. It’s very unexpected to have it open an external link. Performance isn’t strictly a part of Support, but it’s worked having it there for long enough that it’s probably not a bother.
Python
mit
gov-cjwaszczuk/notifications-admin,alphagov/notifications-admin,alphagov/notifications-admin,gov-cjwaszczuk/notifications-admin,gov-cjwaszczuk/notifications-admin,gov-cjwaszczuk/notifications-admin,alphagov/notifications-admin,alphagov/notifications-admin
d565786278eaf32761957dd1e064a5d549ef3ab4
praw/models/reddit/mixins/savable.py
praw/models/reddit/mixins/savable.py
"""Provide the SavableMixin class.""" from ....const import API_PATH class SavableMixin(object): """Interface for RedditBase classes that can be saved.""" def save(self, category=None): """Save the object. :param category: The category to save to (Default: None). """ self._reddit.post(API_PATH['save'], data={'category': category, 'id': self.fullname}) def unsave(self): """Unsave the object.""" self._reddit.post(API_PATH['unsave'], data={'id': self.fullname})
"""Provide the SavableMixin class.""" from ....const import API_PATH class SavableMixin(object): """Interface for RedditBase classes that can be saved.""" def save(self, category=None): """Save the object. :param category: (Gold) The category to save to (Default: None). If your user does not have gold this value is ignored by Reddit. """ self._reddit.post(API_PATH['save'], data={'category': category, 'id': self.fullname}) def unsave(self): """Unsave the object.""" self._reddit.post(API_PATH['unsave'], data={'id': self.fullname})
Clarify that category is a gold feature for saving an item
Clarify that category is a gold feature for saving an item
Python
bsd-2-clause
13steinj/praw,RGood/praw,RGood/praw,darthkedrik/praw,darthkedrik/praw,leviroth/praw,gschizas/praw,leviroth/praw,gschizas/praw,praw-dev/praw,nmtake/praw,praw-dev/praw,nmtake/praw,13steinj/praw
55dfcce3d2c42433249f401ff5021820c341a691
entity_networks/activations.py
entity_networks/activations.py
from __future__ import absolute_import from __future__ import print_function from __future__ import division import tensorflow as tf def prelu(features, initializer=tf.constant_initializer(1), name=None): """ Implementation of [Parametric ReLU](https://arxiv.org/abs/1502.01852) borrowed from Keras. """ with tf.variable_scope(name or 'PReLU'): alpha = tf.get_variable('alpha', shape=features.get_shape().as_list()[1:], initializer=initializer) pos = tf.nn.relu(features) neg = alpha * (features - tf.abs(features)) * 0.5 return pos + neg
from __future__ import absolute_import from __future__ import print_function from __future__ import division import tensorflow as tf def prelu(features, initializer=None, name=None): """ Implementation of [Parametric ReLU](https://arxiv.org/abs/1502.01852) borrowed from Keras. """ with tf.variable_scope(name or 'PReLU'): alpha = tf.get_variable('alpha', shape=features.get_shape().as_list()[1:], initializer=initializer) pos = tf.nn.relu(features) neg = alpha * (features - tf.abs(features)) * 0.5 return pos + neg
Remove default initializer from prelu
Remove default initializer from prelu
Python
mit
mikalyoung/recurrent-entity-networks,jimfleming/recurrent-entity-networks,mikalyoung/recurrent-entity-networks,jimfleming/recurrent-entity-networks
8a8d4905c169b9a1060f1283d0286c433af24f43
word2gauss/words.py
word2gauss/words.py
from itertools import islice from .embeddings import text_to_pairs def iter_pairs(fin, vocab, batch_size=10, nsamples=2, window=5): ''' Convert a document stream to batches of pairs used for training embeddings. iter_pairs is a generator that yields batches of pairs that can be passed to GaussianEmbedding.train fin = an iterator of documents / sentences (e.g. a file like object) Each element is a string of raw text vocab = something implementing the Vocabulary interface batch_size = size of batches window = Number of words to the left and right of center word to include as positive pairs nsamples = number of negative samples to drawn for each center word ''' documents = iter(fin) batch = list(islice(documents, batch_size)) while len(batch) > 0: text = [ vocab.tokenize(doc, remove_oov=False, return_ids=True) for doc in batch ] pairs = text_to_pairs(text, vocab.random_ids, nsamples_per_word=nsamples, half_window_size=window) yield pairs batch = list(islice(documents, batch_size))
from itertools import islice from .embeddings import text_to_pairs def iter_pairs(fin, vocab, batch_size=10, nsamples=2, window=5): ''' Convert a document stream to batches of pairs used for training embeddings. iter_pairs is a generator that yields batches of pairs that can be passed to GaussianEmbedding.train fin = an iterator of documents / sentences (e.g. a file like object) Each element is a string of raw text vocab = something implementing the Vocabulary interface batch_size = size of batches window = Number of words to the left and right of center word to include as positive pairs nsamples = number of negative samples to drawn for each center word ''' documents = iter(fin) batch = list(islice(documents, batch_size)) while len(batch) > 0: text = [ vocab.tokenize_ids(doc, remove_oov=False) for doc in batch ] pairs = text_to_pairs(text, vocab.random_ids, nsamples_per_word=nsamples, half_window_size=window) yield pairs batch = list(islice(documents, batch_size))
Change the interface on tokenize in vocabulary
Change the interface on tokenize in vocabulary
Python
mit
seomoz/word2gauss,seomoz/word2gauss
8348f46fb78b55c5d2bcd6401f4041e8890072db
gviewer/keys/vim.py
gviewer/keys/vim.py
from collections import OrderedDict keys = OrderedDict([ ("j", "down"), ("k", "up"), ("ctrl f", "page down"), ("ctrl b", "page up")] )
from collections import OrderedDict keys = OrderedDict([ ("j", "down"), ("k", "up"), ("ctrl f", "page down"), ("ctrl d", "page down"), ("ctrl b", "page up"), ("ctrl u", "page up")] )
Add ctrl+d/ctrl+u for page down and page up
Add ctrl+d/ctrl+u for page down and page up
Python
mit
chhsiao90/gviewer
e2e9a7a0339ae269a239156972595d6ff590cebe
src/yunohost/data_migrations/0009_migrate_to_apps_json.py
src/yunohost/data_migrations/0009_migrate_to_apps_json.py
from moulinette.utils.log import getActionLogger from yunohost.app import app_fetchlist, app_removelist from yunohost.tools import Migration logger = getActionLogger('yunohost.migration') class MyMigration(Migration): "Migrate from official.json to apps.json" def migrate(self): # Remove official.json list app_removelist(name="yunohost") # Replace by apps.json list app_fetchlist(name="yunohost", url="https://app.yunohost.org/apps.json") def backward(self): # Remove apps.json list app_removelist(name="yunohost") # Replace by official.json list app_fetchlist(name="yunohost", url="https://app.yunohost.org/official.json")
from moulinette.utils.log import getActionLogger from yunohost.app import app_fetchlist, app_removelist, _read_appslist_list from yunohost.tools import Migration logger = getActionLogger('yunohost.migration') class MyMigration(Migration): "Migrate from official.json to apps.json" def migrate(self): # Remove all the deprecated lists lists_to_remove = [ "https://app.yunohost.org/official.json", "https://app.yunohost.org/community.json", "https://labriqueinter.net/apps/labriqueinternet.json" ] appslists = _read_appslist_list() for appslist, infos in appslists.items(): if infos["url"] in lists_to_remove: app_removelist(name=appslist) # Replace by apps.json list app_fetchlist(name="yunohost", url="https://app.yunohost.org/apps.json") def backward(self): # Remove apps.json list app_removelist(name="yunohost") # Replace by official.json list app_fetchlist(name="yunohost", url="https://app.yunohost.org/official.json")
Remove all deprecated lists, not just 'yunohost'
Remove all deprecated lists, not just 'yunohost'
Python
agpl-3.0
YunoHost/yunohost,YunoHost/moulinette-yunohost,YunoHost/yunohost,YunoHost/yunohost,YunoHost/moulinette-yunohost,YunoHost/moulinette-yunohost,YunoHost/yunohost,YunoHost/moulinette-yunohost,YunoHost/moulinette-yunohost
8b5973b5581fb6da27891f8c2256886c1dc7e8a8
server/src/db_layer.py
server/src/db_layer.py
from pymongo import MongoClient # Magic decorator for defining constants def constant(f): def fset(self, value): raise TypeError def fget(self): return f() return property(fget, fset) class Model: def __init__(self): pass @staticmethod @constant def COLLECTION_NAME(): return Model.__name__ class Post(Model): def __init__(self): Model.__init__(self) @staticmethod @constant def COLLECTION_NAME(): return "posts" class GideonDatabaseClient: @staticmethod @constant def DATABASE_NAME(): return "test-database" def __init__(self): self.client = MongoClient("mongodb://localhost:27017/") self.db = self.client[GideonDatabaseClient.DATABASE_NAME()] def get_collection(self, model_cls): return self.db[model_cls.COLLECTION_NAME()]
from pymongo import MongoClient # Magic decorator for defining constants def constant(f): def fset(self, value): raise TypeError def fget(self): return f() return property(fget, fset) class Model: def __init__(self): pass @staticmethod @constant def COLLECTION_NAME(): return Model.__name__ class Post(Model): def __init__(self): Model.__init__(self) @staticmethod @constant def COLLECTION_NAME(): return "posts" class User(Model): def __init__(self): Model.__init__(self) @staticmethod @constant def COLLECTION_NAME(): return "users" class GideonDatabaseClient: @staticmethod @constant def DATABASE_NAME(): return "test-database" def __init__(self): self.client = MongoClient("mongodb://localhost:27017/") self.db = self.client[GideonDatabaseClient.DATABASE_NAME()] def get_collection(self, model_cls): return self.db[model_cls.COLLECTION_NAME()]
Add users to the list of models.
Add users to the list of models.
Python
mit
Opportunity-Hack-2015-Arizona/Team1,Opportunity-Hack-2015-Arizona/Team1,Opportunity-Hack-2015-Arizona/Team1
849fbdf724528df99f2ac53d389274f7c2631f11
invitation/admin.py
invitation/admin.py
from django.contrib import admin from invitation.models import InvitationKey, InvitationUser, InvitationRequest, InvitationCode class InvitationKeyAdmin(admin.ModelAdmin): list_display = ('__unicode__', 'from_user', 'date_invited', 'key_expired') class InvitationUserAdmin(admin.ModelAdmin): list_display = ('inviter', 'invitations_remaining') def invite_user(modeladmin, request, queryset): for invitation_request in queryset.all(): invitation = InvitationKey.objects.create_invitation(request.user) invitation.send_to(invitation_request.email) invitation_request.invited = True invitation_request.save() invite_user.short_description = "Invite this user" class InvitationRequestAdmin(admin.ModelAdmin): list_display = ('email', 'invited') actions = [invite_user] admin.site.register(InvitationKey, InvitationKeyAdmin) admin.site.register(InvitationUser, InvitationUserAdmin) admin.site.register(InvitationRequest, InvitationRequestAdmin) admin.site.register(InvitationCode)
from django.contrib import admin from invitation.models import InvitationKey, InvitationUser, InvitationRequest, InvitationCode class InvitationKeyAdmin(admin.ModelAdmin): list_display = ('__unicode__', 'from_user', 'date_invited', 'key_expired') class InvitationUserAdmin(admin.ModelAdmin): list_display = ('inviter', 'invitations_remaining') def invite_user(modeladmin, request, queryset): for invitation_request in queryset.all(): invitation = InvitationKey.objects.create_invitation(request.user) invitation.send_to(invitation_request.email) invitation_request.invited = True invitation_request.save() invite_user.short_description = "Invite selected invitation requests" class InvitationRequestAdmin(admin.ModelAdmin): list_display = ('email', 'invited') actions = [invite_user] admin.site.register(InvitationKey, InvitationKeyAdmin) admin.site.register(InvitationUser, InvitationUserAdmin) admin.site.register(InvitationRequest, InvitationRequestAdmin) admin.site.register(InvitationCode)
Improve the invite_user action name.
Improve the invite_user action name.
Python
bsd-3-clause
adieu/django-invitation
ba23baaee867ed79762fb3e3ac10af47d028d9ed
ergae/app.py
ergae/app.py
# ergae --- Earth Reader on Google App Engine # Copyright (C) 2014 Hong Minhee # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import absolute_import from flask import Flask from .dropbox import mod app = Flask(__name__) app.register_blueprint(mod)
# ergae --- Earth Reader on Google App Engine # Copyright (C) 2014 Hong Minhee # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as # published by the Free Software Foundation, either version 3 of the # License, or (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU Affero General Public License for more details. # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <http://www.gnu.org/licenses/>. from __future__ import absolute_import import os from flask import Flask from .config import get_config, set_config from .dropbox import mod app = Flask(__name__) app.register_blueprint(mod) app.secret_key = get_config('secret_key') if app.secret_key is None: app.secret_key = os.urandom(24) set_config('secret_key', app.secret_key)
Create random HMAC secret and save it
Create random HMAC secret and save it
Python
agpl-3.0
earthreader/ergae
82d90487a43e309074e5572b6ac529a707345274
fileutils.py
fileutils.py
##-*- coding: utf-8 -*- #!/usr/bin/python """ Utilities related to Files. """ from io import FileIO, BufferedWriter __author__ = 'SeomGi, Han' __credits__ = ['SeomGi, Han'] __copyright__ = 'Copyright 2015, Python Utils Project' __license__ = 'MIT' __version__ = '1.0.0' __maintainer__ = 'SeomGi, Han' __email__ = 'iandmyhand@gmail.com' __status__ = 'Production' class FileUtils: def copy_buffered_io_to_file(self, buffered_io, file_path): with FileIO(file_path, mode='wb') as raw_output_io: with BufferedWriter(raw_output_io) as writer: while 1: line = buffered_io.readline() if not line: break writer.write(line) buffered_io.close()
##-*- coding: utf-8 -*- #!/usr/bin/python """ Utilities related to Files. """ import os from io import FileIO, BufferedReader, BufferedWriter __author__ = 'SeomGi, Han' __credits__ = ['SeomGi, Han'] __copyright__ = 'Copyright 2015, Python Utils Project' __license__ = 'MIT' __version__ = '1.0.0' __maintainer__ = 'SeomGi, Han' __email__ = 'iandmyhand@gmail.com' __status__ = 'Production' class FileUtils: def copy_file_stream_to_file(self, file, to_path): self.copy_buffered_io_to_file(BufferedReader(file), to_path) def copy_buffered_io_to_file(self, buffered_io, file_path): os.makedirs(file_path[:file_path.rfind('/') + 1], exist_ok=True) with FileIO(file_path, mode='wb') as raw_output_io: with BufferedWriter(raw_output_io) as writer: while 1: line = buffered_io.readline() if not line: break writer.write(line) buffered_io.close()
Add wrapped raw file copy function that use BufferedReader. And add logic to make directory if target directory isn't exist.
Add wrapped raw file copy function that use BufferedReader. And add logic to make directory if target directory isn't exist.
Python
mit
iandmyhand/python-utils
a353e2227e9d8f7c5ccdb890fa70d4166751af22
example/wsgi.py
example/wsgi.py
""" WSGI config for test2 project. This module contains the WSGI application used by Django's development server and any production WSGI deployments. It should expose a module-level variable named ``application``. Django's ``runserver`` and ``runfcgi`` commands discover this application via the ``WSGI_APPLICATION`` setting. Usually you will have the standard Django WSGI application here, but it also might make sense to replace the whole Django WSGI application with a custom one that later delegates to the Django one. For example, you could introduce WSGI middleware here, or combine a Django application with an application of another framework. """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test2.settings") # This application object is used by any WSGI server configured to use this # file. This includes Django's development server, if the WSGI_APPLICATION # setting points here. from django.core.wsgi import get_wsgi_application application = get_wsgi_application() # Apply WSGI middleware here. # from helloworld.wsgi import HelloWorldApplication # application = HelloWorldApplication(application)
import os from django.core.wsgi import get_wsgi_application os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test2.settings") application = get_wsgi_application()
Fix an occurrence of E402
Fix an occurrence of E402
Python
bsd-3-clause
diegobz/django-admin-sso,matthiask/django-admin-sso,matthiask/django-admin-sso,diegobz/django-admin-sso
0418609dd429a45a327ace191514ce2c4233ea11
tests_django/test_settings.py
tests_django/test_settings.py
""" Test Django settings """ import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = 'fake-key' INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'chatterbot.ext.django_chatterbot', 'tests_django', ] CHATTERBOT = { 'name': 'Test Django ChatterBot', 'trainer': 'chatterbot.trainers.ChatterBotCorpusTrainer', 'training_data': [ 'chatterbot.corpus.english.greetings' ], 'initialize': False } ROOT_URLCONF = 'chatterbot.ext.django_chatterbot.urls' MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', ) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } }
""" Test Django settings """ import os BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) SECRET_KEY = 'fake-key' INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'chatterbot.ext.django_chatterbot', 'tests_django', ] CHATTERBOT = { 'name': 'Test Django ChatterBot', 'trainer': 'chatterbot.trainers.ChatterBotCorpusTrainer', 'training_data': [ 'chatterbot.corpus.english.greetings' ], 'initialize': False } ROOT_URLCONF = 'chatterbot.ext.django_chatterbot.urls' MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.auth.middleware.SessionAuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.security.SecurityMiddleware', ) DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(BASE_DIR, 'db.sqlite3'), } } USE_TZ = True
Set USE_TZ in test settings
Set USE_TZ in test settings
Python
bsd-3-clause
davizucon/ChatterBot,maclogan/VirtualPenPal,Reinaesaya/OUIRL-ChatBot,gunthercox/ChatterBot,Gustavo6046/ChatterBot,vkosuri/ChatterBot,Reinaesaya/OUIRL-ChatBot
4fa22298598add3541baf8ac4b3636eb4c64b9ec
fuzzer/tasks.py
fuzzer/tasks.py
import redis from celery import Celery from .Fuzzer import Fuzzer import os import time import driller.config as config import logging l = logging.getLogger("fuzzer.tasks") backend_url = "redis://%s:%d" % (config.REDIS_HOST, config.REDIS_PORT) app = Celery('fuzzer', broker=config.BROKER_URL, backend=backend_url) @app.task def drill(binary, input, fuzz_bitmap, exit_on_eof=False): binary_path = os.path.join(config.BINARY_DIR, binary) fuzzer = Fuzzer(binary_path, "tests", config.FUZZER_INSTANCES) try: fuzzer.start() except Fuzzer.EarlyCrash: l.info("binary crashed on dummy testcase, moving on...") return 0 # start the fuzzer and poll for a crash or timeout fuzzer.start() while not fuzzer.found_crash() and not fuzzer.timed_out(): time.sleep(config.CRASH_CHECK_INTERVAL) # make sure to kill the fuzzers when we're done fuzzer.kill() return fuzzer.found_crash()
import redis from celery import Celery from .Fuzzer import Fuzzer import os import time import driller.config as config import logging l = logging.getLogger("fuzzer.tasks") backend_url = "redis://%s:%d" % (config.REDIS_HOST, config.REDIS_PORT) app = Celery('fuzzer', broker=config.BROKER_URL, backend=backend_url) @app.task def fuzz(binary): binary_path = os.path.join(config.BINARY_DIR, binary) fuzzer = Fuzzer(binary_path, "tests", config.FUZZER_INSTANCES) try: fuzzer.start() except Fuzzer.EarlyCrash: l.info("binary crashed on dummy testcase, moving on...") return 0 # start the fuzzer and poll for a crash or timeout fuzzer.start() while not fuzzer.found_crash() and not fuzzer.timed_out(): time.sleep(config.CRASH_CHECK_INTERVAL) # make sure to kill the fuzzers when we're done fuzzer.kill() return fuzzer.found_crash()
Fix function declaration for fuzz task
Fix function declaration for fuzz task
Python
bsd-2-clause
shellphish/driller
45bb9872978311774b97d9243358ffe9eaad3389
client/main.py
client/main.py
import yaml import sys from conversation import Conversation def isLocal(): return len(sys.argv) > 1 and sys.argv[1] == "--local" if isLocal(): from local_mic import Mic else: from mic import Mic if __name__ == "__main__": print "===========================================================" print " JASPER The Talking Computer " print " Copyright 2013 Shubhro Saha & Charlie Marsh " print "===========================================================" profile = yaml.safe_load(open("profile.yml", "r")) mic = Mic("languagemodel.lm", "dictionary.dic", "languagemodel_persona.lm", "dictionary_persona.dic") mic.say("How can I be of service, %s?" % (profile["first_name"])) conversation = Conversation("JASPER", mic, profile) conversation.handleForever()
import yaml import sys from conversation import Conversation def isLocal(): return len(sys.argv) > 1 and sys.argv[1] == "--local" if isLocal(): from local_mic import Mic else: from mic import Mic if __name__ == "__main__": print "===========================================================" print " JASPER The Talking Computer " print " Copyright 2013 Shubhro Saha & Charlie Marsh " print "===========================================================" profile = yaml.safe_load(open("profile.yml", "r")) mic = Mic("languagemodel.lm", "dictionary.dic", "languagemodel_persona.lm", "dictionary_persona.dic") addendum = "" if 'first_name' in profile: addendum = ", %s" % profile["first_name"] mic.say("How can I be of service%s?" % addendum) conversation = Conversation("JASPER", mic, profile) conversation.handleForever()
Check if first_name is set for profile beforehand
Check if first_name is set for profile beforehand
Python
mit
syardumi/jasper-client,benhoff/jasper-client,tsaitsai/jasper-client,densic/HomeAutomation,sunu/jasper-client,fritz-fritz/jasper-client,jskye/voicehud-jasper,clumsical/hackthehouse-marty,djeraseit/jasper-client,markferry/jasper-client,jasperproject/jasper-client,densic/HomeAutomation,sunu/jasper-client,rowhit/jasper-client,jskye/voicehud-jasper,jasperproject/jasper-client,brad999/nikita-client,tsaitsai/jasper-client,aish9r/jasper-client,bdizen/jasper-client,sanyaade-iot/jasper-client,steppy345/jasper-client,joekinley/jasper-client,rowhit/jasper-client,benhoff/jasper-client,brad999/nikita-client,rahul1193/jasper-client,Siretu/jasper-client,markferry/jasper-client,rahul1193/jasper-client,aish9r/jasper-client,fritz-fritz/jasper-client,auhlig/jasper-client,clumsical/hackthehouse-marty,rab206/self-proj-pi,Siretu/jasper-client,brad999/nikita,Brandon32/jasper-client,skylarker/jasper-client,djeraseit/jasper-client,MaakbareWereld/storyteller,steppy345/jasper-client,zanbel/david,skylarker/jasper-client,sukhoi/jasper-client,brad999/nikita,zanbel/david,ajay-gandhi/jasper-client,auhlig/jasper-client,sanyaade-iot/jasper-client,syardumi/jasper-client,joekinley/jasper-client,ajay-gandhi/jasper-client,Brandon32/jasper-client,sukhoi/jasper-client,rab206/self-proj-pi,assanee/jasper-client,assanee/jasper-client,DarrenRainey/jasper-client,MaakbareWereld/storyteller,DarrenRainey/jasper-client,bdizen/jasper-client
d0f425d215f0d1c4f57a3517ad3e4c15f2b35e86
tests/travis_test/TravisBuildTest.py
tests/travis_test/TravisBuildTest.py
import unittest as ut class TravisBuildTest(ut.TestCase): def test_success(self): self.assertEqual(1, 1, "1 is not equal to 1?!") def main(): ut.main() if __name__ == '__main__': main()
import unittest as ut class TravisBuildTest(ut.TestCase): def test_success(self): self.assertEqual(1, 1, "1 is not equal to 1?!") def test_failing(self): self.assertEqual(1, 2) def main(): ut.main() if __name__ == '__main__': main()
Add failing test to dev branch to test, if master badge stay green
Add failing test to dev branch to test, if master badge stay green
Python
mit
PatrikValkovic/grammpy
5dbdac674692b67f8f08627453b145c4d24ac32f
tests/integration/conftest.py
tests/integration/conftest.py
# coding: utf-8 """Pytest config.""" import os import sys import pytest from kiteconnect import KiteConnect sys.path.append(os.path.join(os.path.dirname(__file__), '../helpers')) def pytest_addoption(parser): """Add available args.""" parser.addoption("--api-key", action="store", default="Api key") parser.addoption("--access-token", action="store", default="Access token") parser.addoption("--root", action="store", default="") def pytest_generate_tests(metafunc): """This is called for every test. Only get/set command line arguments. If the argument is specified in the list of test "fixturenames".""" access_token = metafunc.config.option.access_token api_key = metafunc.config.option.api_key root = metafunc.config.option.root if "access_token" in metafunc.fixturenames and access_token is not None: metafunc.parametrize("access_token", [access_token]) if "api_key" in metafunc.fixturenames and api_key is not None: metafunc.parametrize("api_key", [api_key]) if "root" in metafunc.fixturenames and root is not None: metafunc.parametrize("root", [root]) @pytest.fixture() def kiteconnect(api_key, access_token, root): """Init Kite connect object.""" return KiteConnect(api_key=api_key, access_token=access_token, root=root or None)
# coding: utf-8 """Pytest config.""" import os import sys import pytest from kiteconnect import KiteConnect sys.path.append(os.path.join(os.path.dirname(__file__), '../helpers')) def pytest_addoption(parser): """Add available args.""" parser.addoption("--api-key", action="store", default="Api key") parser.addoption("--access-token", action="store", default="Access token") parser.addoption("--root-url", action="store", default="") def pytest_generate_tests(metafunc): """This is called for every test. Only get/set command line arguments. If the argument is specified in the list of test "fixturenames".""" access_token = metafunc.config.option.access_token api_key = metafunc.config.option.api_key root_url = metafunc.config.option.root_url if "access_token" in metafunc.fixturenames and access_token is not None: metafunc.parametrize("access_token", [access_token]) if "api_key" in metafunc.fixturenames and api_key is not None: metafunc.parametrize("api_key", [api_key]) if "root_url" in metafunc.fixturenames and root_url is not None: metafunc.parametrize("root_url", [root_url]) @pytest.fixture() def kiteconnect(api_key, access_token, root_url): """Init Kite connect object.""" return KiteConnect(api_key=api_key, access_token=access_token, root=root_url or None)
Rename cmd flag root to root-url for integrated tests
Rename cmd flag root to root-url for integrated tests
Python
mit
rainmattertech/pykiteconnect
15808c86b273363c9f6466107d0cbc14030a97fa
ykman/scanmap/__init__.py
ykman/scanmap/__init__.py
from enum import Enum from . import us class KEYBOARD_LAYOUT(Enum): US = 'US Keyboard Layout' def get_scan_codes(data, keyboard_layout=KEYBOARD_LAYOUT.US): if keyboard_layout == KEYBOARD_LAYOUT.US: scancodes = us.scancodes else: raise ValueError('Keyboard layout not supported!') try: return bytes(bytearray(scancodes[c] for c in data)) except KeyError: raise ValueError('Character not available in keyboard layout!')
from enum import Enum from . import us class KEYBOARD_LAYOUT(Enum): US = 'US Keyboard Layout' def get_scan_codes(data, keyboard_layout=KEYBOARD_LAYOUT.US): if keyboard_layout == KEYBOARD_LAYOUT.US: scancodes = us.scancodes else: raise ValueError('Keyboard layout not supported!') try: return bytes(bytearray(scancodes[c] for c in data)) except KeyError as e: raise ValueError('Unsupported character: %s' % e.args[0])
Clarify what character that was missing
Clarify what character that was missing
Python
bsd-2-clause
Yubico/yubikey-manager,Yubico/yubikey-manager
611218f302d30213fece13c1a8997f87a44afa70
djangosqladmin/databases/views.py
djangosqladmin/databases/views.py
from django.shortcuts import render from django.http import HttpResponse def dashboard(request): return HttpResponse('SUCCESS!')
from django.shortcuts import render from django.http import HttpResponse def dashboard(request): context = {} if request.user.is_authenticated: context['databases'] = request.user.database_set.all() return render(request, 'databases/dashboard.html', context)
Add databases to dashboard context
Add databases to dashboard context
Python
mit
jakesen/djangosqladmin,jakesen/djangosqladmin,jakesen/djangosqladmin
151c3484da58fa02f7d2c69454be3cb4e3395d05
recipes/recipe_modules/bot_update/tests/ensure_checkout.py
recipes/recipe_modules/bot_update/tests/ensure_checkout.py
# Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from recipe_engine import post_process DEPS = [ 'bot_update', 'gclient', 'recipe_engine/json', ] def RunSteps(api): api.gclient.set_config('depot_tools') api.bot_update.ensure_checkout() def GenTests(api): yield ( api.test('basic') + api.post_process(post_process.StatusCodeIn, 0) + api.post_process(post_process.DropExpectation) ) yield ( api.test('failure') + api.override_step_data( 'bot_update', api.json.output({'did_run': True}), retcode=1) + api.post_process(post_process.StatusCodeIn, 1) + api.post_process(post_process.DropExpectation) )
# Copyright 2018 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from recipe_engine import post_process DEPS = [ 'bot_update', 'gclient', 'recipe_engine/json', ] def RunSteps(api): api.gclient.set_config('depot_tools') api.bot_update.ensure_checkout() def GenTests(api): yield ( api.test('basic') + api.post_process(post_process.StatusSuccess) + api.post_process(post_process.DropExpectation) ) yield ( api.test('failure') + api.override_step_data( 'bot_update', api.json.output({'did_run': True}), retcode=1) + api.post_process(post_process.StatusAnyFailure) + api.post_process(post_process.DropExpectation) )
Replace post-process checks with ones that are not deprecated
Replace post-process checks with ones that are not deprecated R=40f3d43a28ebae3cb819288542e1c84d73d962d5@chromium.org Bug: 899266 Change-Id: Ia9b1f38590d636fa2858a2bd0bbf75d6b2cfe8fa Reviewed-on: https://chromium-review.googlesource.com/c/1483033 Reviewed-by: Robbie Iannucci <40f3d43a28ebae3cb819288542e1c84d73d962d5@chromium.org> Reviewed-by: John Budorick <17d38a2d68c6a07a3ab0ce4a2873c5acefbd3dbb@chromium.org> Commit-Queue: Sergiy Belozorov <aadb4a11584aa9878242ea5d9e4b7e3429654579@chromium.org>
Python
bsd-3-clause
CoherentLabs/depot_tools,CoherentLabs/depot_tools
7cc357584ddd4f8e57783b5e0a462b5ad0daf411
footer.py
footer.py
import htmlify from socket import gethostname as hostname from time import time as unixTime def showFooter(): # Footer htmlify.dispHTML("br") htmlify.dispHTML("hr") heart = "<i class=\"fa fa-heart\" aria-hidden=\"true\"></i>" so = "<i class=\"fa fa-stack-overflow\" aria-hidden=\"true\"></i>" tProfileLink = htmlify.getHTML("a", contents="Theo C", href="http://github.com/DyingEcho") iProfileLink = htmlify.getHTML("a", contents="Isaac L", href="http://github.com/il8677") htmlify.dispHTML("small", contents="Made with " + heart + " and " + so + " by " + tProfileLink + " and " + iProfileLink) renderTime = unixTime() htmlify.dispHTML("br") htmlify.dispHTML("small", contents="Rendered at " + str(round(renderTime)) + " by " + hostname())
import htmlify from socket import gethostname as hostname from time import time as unixTime def showFooter(): # Footer htmlify.dispHTML("br") htmlify.dispHTML("hr") heart = "<i class=\"fa fa-heart\" aria-hidden=\"true\" title=\"love\"></i>" so = "<i class=\"fa fa-stack-overflow\" aria-hidden=\"true\" title=\"StackOverflow\"></i>" tProfileLink = htmlify.getHTML("a", contents="Theo C", href="http://github.com/DyingEcho") iProfileLink = htmlify.getHTML("a", contents="Isaac L", href="http://github.com/il8677") htmlify.dispHTML("small", contents="Made with " + heart + " and " + so + " by " + tProfileLink + " and " + iProfileLink) renderTime = unixTime() htmlify.dispHTML("br") htmlify.dispHTML("small", contents="Rendered at " + str(round(renderTime)) + " by " + hostname())
Add titles to FA icons
Add titles to FA icons
Python
apache-2.0
ISD-Sound-and-Lights/InventoryControl
42d038f09bb9b24802ee78f92a5c7a309acf3a7a
zerver/migrations/0301_fix_unread_messages_in_deactivated_streams.py
zerver/migrations/0301_fix_unread_messages_in_deactivated_streams.py
from django.db import connection, migrations from django.db.backends.postgresql.schema import DatabaseSchemaEditor from django.db.migrations.state import StateApps def mark_messages_read(apps: StateApps, schema_editor: DatabaseSchemaEditor) -> None: Stream = apps.get_model("zerver", "Stream") deactivated_stream_ids = list(Stream.objects.filter(deactivated=True).values_list('id', flat=True)) with connection.cursor() as cursor: for i in deactivated_stream_ids: cursor.execute(f""" UPDATE zerver_usermessage SET flags = flags | 1 FROM zerver_message INNER JOIN zerver_stream ON zerver_stream.recipient_id = zerver_message.recipient_id WHERE zerver_message.id = zerver_usermessage.message_id AND zerver_stream.id = {i}; """) class Migration(migrations.Migration): """ We're changing the stream deactivation process to make it mark all messages in the stream as read. For things to be consistent with streams that have been deactivated before this change, we need a migration to fix those old streams, to have all messages marked as read. """ atomic = False dependencies = [ ('zerver', '0300_add_attachment_is_web_public'), ] operations = [ migrations.RunPython(mark_messages_read, reverse_code=migrations.RunPython.noop), ]
from django.db import migrations class Migration(migrations.Migration): """ We're changing the stream deactivation process to make it mark all messages in the stream as read. For things to be consistent with streams that have been deactivated before this change, we need a migration to fix those old streams, to have all messages marked as read. """ dependencies = [ ('zerver', '0300_add_attachment_is_web_public'), ] operations = [ migrations.RunSQL( sql=""" UPDATE zerver_usermessage SET flags = flags | 1 FROM zerver_message INNER JOIN zerver_stream ON zerver_stream.recipient_id = zerver_message.recipient_id WHERE zerver_message.id = zerver_usermessage.message_id AND zerver_stream.deactivated; """, reverse_sql="", ), ]
Fix 0301 to replace a Python loop with SQL.
migrations: Fix 0301 to replace a Python loop with SQL. The previous code is correctly flagged by semgrep 0.23 as a violation of our sql-format rule. Signed-off-by: Anders Kaseorg <dfdb7392591db597bc41cf266a9c3bc12a2706e5@zulip.com>
Python
apache-2.0
zulip/zulip,andersk/zulip,showell/zulip,punchagan/zulip,hackerkid/zulip,showell/zulip,eeshangarg/zulip,showell/zulip,rht/zulip,rht/zulip,andersk/zulip,eeshangarg/zulip,zulip/zulip,punchagan/zulip,showell/zulip,andersk/zulip,hackerkid/zulip,rht/zulip,andersk/zulip,punchagan/zulip,zulip/zulip,punchagan/zulip,showell/zulip,eeshangarg/zulip,showell/zulip,eeshangarg/zulip,rht/zulip,kou/zulip,hackerkid/zulip,punchagan/zulip,zulip/zulip,rht/zulip,andersk/zulip,eeshangarg/zulip,kou/zulip,hackerkid/zulip,kou/zulip,andersk/zulip,andersk/zulip,rht/zulip,kou/zulip,hackerkid/zulip,hackerkid/zulip,hackerkid/zulip,eeshangarg/zulip,kou/zulip,zulip/zulip,zulip/zulip,eeshangarg/zulip,kou/zulip,showell/zulip,punchagan/zulip,zulip/zulip,rht/zulip,kou/zulip,punchagan/zulip
172b6b417cbd3bc2ffacf7f38b3a49f84510d13c
localeurl/models.py
localeurl/models.py
from django.conf import settings from django.core import urlresolvers from django.utils import translation from localeurl import utils def reverse(*args, **kwargs): reverse_kwargs = kwargs.get('kwargs', {}) locale = utils.supported_language(reverse_kwargs.pop('locale', translation.get_language())) url = django_reverse(*args, **kwargs) _, path = utils.strip_script_prefix(url) return utils.locale_url(path, locale) django_reverse = None def patch_reverse(): """ Monkey-patches the urlresolvers.reverse function. Will not patch twice. """ global django_reverse if urlresolvers.reverse is not reverse: django_reverse = urlresolvers.reverse urlresolvers.reverse = reverse if settings.USE_I18N: patch_reverse()
from django.conf import settings from django.core import urlresolvers from django.utils import translation from localeurl import utils def reverse(*args, **kwargs): reverse_kwargs = kwargs.get('kwargs', {}) if reverse_kwargs!=None: locale = utils.supported_language(reverse_kwargs.pop('locale', translation.get_language())) else: locale = translation.get_language() url = django_reverse(*args, **kwargs) _, path = utils.strip_script_prefix(url) return utils.locale_url(path, locale) django_reverse = None def patch_reverse(): """ Monkey-patches the urlresolvers.reverse function. Will not patch twice. """ global django_reverse if urlresolvers.reverse is not reverse: django_reverse = urlresolvers.reverse urlresolvers.reverse = reverse if settings.USE_I18N: patch_reverse()
Handle situation when kwargs is None
Handle situation when kwargs is None
Python
mit
jmagnusson/django-localeurl,simonluijk/django-localeurl
aff5a09eb3d61f77cb277b076820481b8ba145d5
tests/test_coroutine.py
tests/test_coroutine.py
import tests try: import asyncio exec('''if 1: def hello_world(result, delay): result.append("Hello") # retrieve the event loop from the policy yield from asyncio.sleep(delay) result.append('World') ''') except ImportError: import trollius as asyncio from trollius import From def hello_world(result, delay): result.append("Hello") # retrieve the event loop from the policy yield From(asyncio.sleep(delay)) result.append('World') class CallbackTests(tests.TestCase): def test_hello_world(self): result = [] self.loop.run_until_complete(hello_world(result, 0.001)) self.assertEqual(result, ['Hello', 'World']) if __name__ == '__main__': import unittest unittest.main()
import tests try: import asyncio exec('''if 1: def hello_world(result, delay): result.append("Hello") # retrieve the event loop from the policy yield from asyncio.sleep(delay) result.append('World') return "." def waiter(result): loop = asyncio.get_event_loop() fut = asyncio.Future(loop=loop) loop.call_soon(fut.set_result, "Future") value = yield from fut result.append(value) value = yield from hello_world(result, 0.001) result.append(value) ''') except ImportError: import trollius as asyncio from trollius import From, Return def hello_world(result, delay): result.append("Hello") # retrieve the event loop from the policy yield From(asyncio.sleep(delay)) result.append('World') raise Return(".") def waiter(result): loop = asyncio.get_event_loop() fut = asyncio.Future(loop=loop) loop.call_soon(fut.set_result, "Future") value = yield From(fut) result.append(value) value = yield From(hello_world(result, 0.001)) result.append(value) class CallbackTests(tests.TestCase): def test_hello_world(self): result = [] self.loop.run_until_complete(hello_world(result, 0.001)) self.assertEqual(result, ['Hello', 'World']) def test_waiter(self): result = [] self.loop.run_until_complete(waiter(result)) self.assertEqual(result, ['Future', 'Hello', 'World', '.']) if __name__ == '__main__': import unittest unittest.main()
Add more complex coroutine example
Add more complex coroutine example
Python
apache-2.0
overcastcloud/aioeventlet
42bfa6b69697c0c093a961df5708f477288a6efa
icekit/plugins/twitter_embed/forms.py
icekit/plugins/twitter_embed/forms.py
import re from django import forms from fluent_contents.forms import ContentItemForm class TwitterEmbedAdminForm(ContentItemForm): def clean_twitter_url(self): """ Make sure the URL provided matches the twitter URL format. """ url = self.cleaned_data['twitter_url'] if url: pattern = re.compile(r'https?://(www\.)?twitter.com/\S+/status(es)?/\S+') if not pattern.match(url): raise forms.ValidationError('Please provide a valid twitter link.') return url
import re from django import forms from fluent_contents.forms import ContentItemForm from icekit.plugins.twitter_embed.models import TwitterEmbedItem class TwitterEmbedAdminForm(ContentItemForm): class Meta: model = TwitterEmbedItem fields = '__all__' def clean_twitter_url(self): """ Make sure the URL provided matches the twitter URL format. """ url = self.cleaned_data['twitter_url'] if url: pattern = re.compile(r'https?://(www\.)?twitter.com/\S+/status(es)?/\S+') if not pattern.match(url): raise forms.ValidationError('Please provide a valid twitter link.') return url
Add model and firld information to form.
Add model and firld information to form.
Python
mit
ic-labs/django-icekit,ic-labs/django-icekit,ic-labs/django-icekit,ic-labs/django-icekit
10a787c9f2147081001239029146b5b049db17f0
featureflow/__init__.py
featureflow/__init__.py
__version__ = '1.16.14' from model import BaseModel from feature import Feature, JSONFeature, TextFeature, CompressedFeature, \ PickleFeature from extractor import Node, Graph, Aggregator, NotEnoughData from bytestream import ByteStream, ByteStreamFeature, ZipWrapper, iter_zip from data import \ IdProvider, UuidProvider, UserSpecifiedIdProvider, StaticIdProvider, \ KeyBuilder, StringDelimitedKeyBuilder, Database, FileSystemDatabase, \ InMemoryDatabase from datawriter import DataWriter from database_iterator import DatabaseIterator from encoder import IdentityEncoder from decoder import Decoder from lmdbstore import LmdbDatabase from objectstore import ObjectStoreDatabase from persistence import PersistenceSettings from iteratornode import IteratorNode from eventlog import EventLog, RedisChannel try: from nmpy import NumpyEncoder, PackedNumpyEncoder, StreamingNumpyDecoder, \ BaseNumpyDecoder, NumpyMetaData, NumpyFeature except ImportError: pass
__version__ = '1.16.14' from model import BaseModel from feature import Feature, JSONFeature, TextFeature, CompressedFeature, \ PickleFeature from extractor import Node, Graph, Aggregator, NotEnoughData from bytestream import ByteStream, ByteStreamFeature, ZipWrapper, iter_zip from data import \ IdProvider, UuidProvider, UserSpecifiedIdProvider, StaticIdProvider, \ KeyBuilder, StringDelimitedKeyBuilder, Database, FileSystemDatabase, \ InMemoryDatabase from datawriter import DataWriter from database_iterator import DatabaseIterator from encoder import IdentityEncoder from decoder import Decoder, PickleDecoder from lmdbstore import LmdbDatabase from objectstore import ObjectStoreDatabase from persistence import PersistenceSettings from iteratornode import IteratorNode from eventlog import EventLog, RedisChannel try: from nmpy import NumpyEncoder, PackedNumpyEncoder, StreamingNumpyDecoder, \ BaseNumpyDecoder, NumpyMetaData, NumpyFeature except ImportError: pass
Add PickleDecoder to the public API
Add PickleDecoder to the public API
Python
mit
JohnVinyard/featureflow,JohnVinyard/featureflow
e62e090f2282426d14dad52a06eeca788789846f
kpi/serializers/v2/user_asset_subscription.py
kpi/serializers/v2/user_asset_subscription.py
# coding: utf-8 from django.utils.translation import ugettext as _ from rest_framework import serializers from kpi.constants import ( ASSET_TYPE_COLLECTION, PERM_DISCOVER_ASSET, PERM_VIEW_ASSET ) from kpi.fields import RelativePrefixHyperlinkedRelatedField from kpi.models import Asset from kpi.models import UserAssetSubscription from kpi.models.object_permission import get_anonymous_user, get_objects_for_user class UserAssetSubscriptionSerializer(serializers.ModelSerializer): url = serializers.HyperlinkedIdentityField( lookup_field='uid', view_name='userassetsubscription-detail' ) asset = RelativePrefixHyperlinkedRelatedField( lookup_field='uid', view_name='asset-detail', queryset=Asset.objects.none() # will be set in __init__() ) uid = serializers.ReadOnlyField() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['asset'].queryset = get_objects_for_user( get_anonymous_user(), [PERM_VIEW_ASSET, PERM_DISCOVER_ASSET], Asset ) class Meta: model = UserAssetSubscription lookup_field = 'uid' fields = ('url', 'asset', 'uid') def validate_asset(self, asset): if asset.asset_type != ASSET_TYPE_COLLECTION: raise serializers.ValidationError( _('Invalid asset type. Only `{asset_type}`').format( asset_type=ASSET_TYPE_COLLECTION ) ) return asset
# coding: utf-8 from django.utils.translation import ugettext as _ from rest_framework import serializers from kpi.constants import ( ASSET_TYPE_COLLECTION, PERM_DISCOVER_ASSET, PERM_VIEW_ASSET ) from kpi.fields import RelativePrefixHyperlinkedRelatedField from kpi.models import Asset from kpi.models import UserAssetSubscription from kpi.models.object_permission import get_anonymous_user, get_objects_for_user class UserAssetSubscriptionSerializer(serializers.ModelSerializer): url = serializers.HyperlinkedIdentityField( lookup_field='uid', view_name='userassetsubscription-detail' ) asset = RelativePrefixHyperlinkedRelatedField( lookup_field='uid', view_name='asset-detail', queryset=Asset.objects.none() # will be set in __init__() ) uid = serializers.ReadOnlyField() def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) self.fields['asset'].queryset = get_objects_for_user( get_anonymous_user(), [PERM_VIEW_ASSET, PERM_DISCOVER_ASSET], Asset ) class Meta: model = UserAssetSubscription lookup_field = 'uid' fields = ('url', 'asset', 'uid') def validate_asset(self, asset): if asset.asset_type != ASSET_TYPE_COLLECTION: raise serializers.ValidationError( _('Invalid asset type. Only `{asset_type}` is allowed').format( asset_type=ASSET_TYPE_COLLECTION ) ) return asset
Improve (a tiny bit) validation error message
Improve (a tiny bit) validation error message
Python
agpl-3.0
kobotoolbox/kpi,kobotoolbox/kpi,kobotoolbox/kpi,kobotoolbox/kpi,kobotoolbox/kpi
984089c3e963998d62768721f23d7e7c72880e39
tests/testapp/test_fhadmin.py
tests/testapp/test_fhadmin.py
from django.contrib.auth.models import User from django.test import Client, TestCase class AdminTest(TestCase): def login(self): client = Client() u = User.objects.create( username="test", is_active=True, is_staff=True, is_superuser=True ) client.force_login(u) return client def test_dashboard(self): client = self.login() response = client.get("/admin/") self.assertContains(response, '<div class="groups">') self.assertContains(response, "<h2>Modules</h2>") self.assertContains(response, "<h2>Preferences</h2>") print(response, response.content.decode("utf-8"))
from django.contrib import admin from django.contrib.auth.models import User from django.test import Client, RequestFactory, TestCase from fhadmin.templatetags.fhadmin_module_groups import generate_group_list class AdminTest(TestCase): def login(self): client = Client() u = User.objects.create( username="test", is_active=True, is_staff=True, is_superuser=True ) client.force_login(u) return client def test_dashboard(self): client = self.login() response = client.get("/admin/") self.assertContains(response, '<div class="groups">') self.assertContains(response, "<h2>Modules</h2>") self.assertContains(response, "<h2>Preferences</h2>") # print(response, response.content.decode("utf-8")) def test_app_list(self): request = RequestFactory().get("/") request.user = User.objects.create(is_superuser=True) groups = list(generate_group_list(admin.sites.site, request)) # from pprint import pprint; pprint(groups) self.assertEqual(groups[0][0], "Modules") self.assertEqual(groups[0][1][0]["app_label"], "testapp") self.assertEqual(len(groups[0][1][0]["models"]), 1)
Test the app list generation a bit
Test the app list generation a bit
Python
bsd-3-clause
feinheit/django-fhadmin,feinheit/django-fhadmin,feinheit/django-fhadmin
d7ea417103bbe5a5c314b65a48dd823aca5df658
webpipe/xrender_test.py
webpipe/xrender_test.py
#!/usr/bin/python -S """ xrender_test.py: Tests for xrender.py """ import unittest import xrender # module under test CSV = """\ name,age <carol>,10 <dave>,20 """ class FunctionsTest(unittest.TestCase): def testRenderCsv(self): html, orig = xrender.RenderCsv('dir/foo.csv', 'foo.csv', CSV) print html def testGuessFileType(self): self.assertEqual('png', xrender.GuessFileType('Rplot001.png')) self.assertEqual('ansi', xrender.GuessFileType('typescript')) def testCleanFilename(self): print xrender.CleanFilename('foo-bar_baz') print xrender.CleanFilename('foo bar') print xrender.CleanFilename('foo bar <>&') print xrender.CleanFilename('foo bar \\ @ ') class ResourcesTest(unittest.TestCase): def testResources(self): res = xrender.Resources() p = res.GetPluginBin('ansi') print p p = res.GetPluginBin('unknown') print p if __name__ == '__main__': unittest.main()
#!/usr/bin/python -S """ xrender_test.py: Tests for xrender.py """ import unittest import xrender # module under test CSV = """\ name,age <carol>,10 <dave>,20 """ class FunctionsTest(unittest.TestCase): def testGuessFileType(self): self.assertEqual('png', xrender.GuessFileType('Rplot001.png')) self.assertEqual('ansi', xrender.GuessFileType('typescript')) def testCleanFilename(self): print xrender.CleanFilename('foo-bar_baz') print xrender.CleanFilename('foo bar') print xrender.CleanFilename('foo bar <>&') print xrender.CleanFilename('foo bar \\ @ ') class ResourcesTest(unittest.TestCase): def testResources(self): res = xrender.Resources() p = res.GetPluginBin('ansi') print p p = res.GetPluginBin('unknown') print p if __name__ == '__main__': unittest.main()
Remove test moved to plugin.
Remove test moved to plugin.
Python
bsd-3-clause
andychu/webpipe,andychu/webpipe,andychu/webpipe,andychu/webpipe,andychu/webpipe
c8c610c7249100e3e514b029a2f4209866910f3a
lumos/source.py
lumos/source.py
""" Client/Source Generates and sends E1.31 packets over UDP """ import socket import struct from packet import E131Packet def ip_from_universe(universe): # derive multicast IP address from Universe high_byte = (universe >> 8) & 0xff low_byte = universe & 0xff return "239.255.{}.{}".format(high_byte, low_byte) class DMXSource(object): def __init__(self, universe=1, network_segment=1): self.universe = universe self.ip = ip_from_universe(universe) # open UDP socket self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) # set ttl to limit network segment reach ttl = struct.pack('b', network_segment) self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl) def send_data(self, data): packet = E131Packet(universe=self.universe, data=data) self.sock.sendto(packet.packet_data, (self.ip, 5568))
""" Client/Source Generates and sends E1.31 packets over UDP """ import socket import struct from packet import E131Packet def ip_from_universe(universe): # derive multicast IP address from Universe high_byte = (universe >> 8) & 0xff low_byte = universe & 0xff return "239.255.{}.{}".format(high_byte, low_byte) class DMXSource(object): """ bind_ip is the IP address assigned to a specific HW interface """ def __init__(self, universe=1, network_segment=1, bind_ip=None): self.universe = universe self.ip = ip_from_universe(universe) # open UDP socket self.sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) if bind_ip: self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_IF, socket.inet_aton(bind_ip)) # set ttl to limit network segment reach ttl = struct.pack('b', network_segment) self.sock.setsockopt(socket.IPPROTO_IP, socket.IP_MULTICAST_TTL, ttl) def send_data(self, data): packet = E131Packet(universe=self.universe, data=data) self.sock.sendto(packet.packet_data, (self.ip, 5568))
Allow a specific address to be specified for sending
Allow a specific address to be specified for sending
Python
bsd-3-clause
ptone/Lumos
f9eac3523d4ab72d3abbfa8ee57801466552f18a
speedbar/modules/hostinformation.py
speedbar/modules/hostinformation.py
from __future__ import absolute_import from .base import BaseModule import os class HostInformationModule(BaseModule): key = 'host' def get_metrics(self): return {'name': os.uname()[1]} def init(): return HostInformationModule
import socket from .base import BaseModule class HostInformationModule(BaseModule): key = 'host' def get_metrics(self): return {'name': socket.gethostname()} def init(): return HostInformationModule
Use more portable function to get hostname
Use more portable function to get hostname This addresses #11
Python
mit
mixcloud/django-speedbar,theospears/django-speedbar,theospears/django-speedbar,mixcloud/django-speedbar,mixcloud/django-speedbar,theospears/django-speedbar
025da22574df8423bfdfea2f7b5bded5ab55054f
manage.py
manage.py
#!/usr/bin/env python import os import sys if __name__ == "__main__": os.environ.setdefault("DJANGO_SETTINGS_MODULE", "QuesCheetah.settings") from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
#!/usr/bin/env python import os import sys if __name__ == "__main__": from django.core.management import execute_from_command_line execute_from_command_line(sys.argv)
DELETE - delete default setting
DELETE - delete default setting
Python
mit
mingkim/QuesCheetah,mingkim/QuesCheetah,mingkim/QuesCheetah,mingkim/QuesCheetah
8623aae8778307648e4a0380d84ca7dc7a63f3f2
oneflow/core/context_processors.py
oneflow/core/context_processors.py
# -*- coding: utf-8 -*- from .models.nonrel import User def mongodb_user(request): if request.user.is_anonymous(): return {u'mongodb_user': None} try: mongodb_user = User.objects.get(id=request.session[u'mongodb_user_id']) except KeyError: mongodb_user = User.objects.get(django_user=request.user.id) # Cache it for next time. request.session[u'mongodb_user_id'] = mongodb_user.id return {u'mongodb_user': mongodb_user}
# -*- coding: utf-8 -*- def mongodb_user(request): """ not the most usefull context manager in the world. """ if request.user.is_anonymous(): return {u'mongodb_user': None} return {u'mongodb_user': request.user.mongo}
Simplify the context processor. Not very useful anymore, in fact.
Simplify the context processor. Not very useful anymore, in fact.
Python
agpl-3.0
1flow/1flow,1flow/1flow,WillianPaiva/1flow,WillianPaiva/1flow,1flow/1flow,WillianPaiva/1flow,WillianPaiva/1flow,1flow/1flow,1flow/1flow,WillianPaiva/1flow
58270d88592e6a097763ce0052ef6a8d22e9bbcb
compose/const.py
compose/const.py
import os import sys DEFAULT_TIMEOUT = 10 IS_WINDOWS_PLATFORM = (sys.platform == "win32") LABEL_CONTAINER_NUMBER = 'com.docker.compose.container-number' LABEL_ONE_OFF = 'com.docker.compose.oneoff' LABEL_PROJECT = 'com.docker.compose.project' LABEL_SERVICE = 'com.docker.compose.service' LABEL_VERSION = 'com.docker.compose.version' LABEL_CONFIG_HASH = 'com.docker.compose.config-hash' HTTP_TIMEOUT = int(os.environ.get('COMPOSE_HTTP_TIMEOUT', os.environ.get('DOCKER_CLIENT_TIMEOUT', 60))) IS_WINDOWS_PLATFORM = (sys.platform == 'win32')
import os import sys DEFAULT_TIMEOUT = 10 HTTP_TIMEOUT = int(os.environ.get('COMPOSE_HTTP_TIMEOUT', os.environ.get('DOCKER_CLIENT_TIMEOUT', 60))) IS_WINDOWS_PLATFORM = (sys.platform == "win32") LABEL_CONTAINER_NUMBER = 'com.docker.compose.container-number' LABEL_ONE_OFF = 'com.docker.compose.oneoff' LABEL_PROJECT = 'com.docker.compose.project' LABEL_SERVICE = 'com.docker.compose.service' LABEL_VERSION = 'com.docker.compose.version' LABEL_CONFIG_HASH = 'com.docker.compose.config-hash'
Remove duplicate and re-order alphabetically
Remove duplicate and re-order alphabetically Signed-off-by: Mazz Mosley <a54aae760072825ca6733a7dfc4aa39211f100a9@houseofmnowster.com>
Python
apache-2.0
johnstep/docker.github.io,mdaue/compose,danix800/docker.github.io,phiroict/docker,jeanpralo/compose,jzwlqx/denverdino.github.io,jonaseck2/compose,denverdino/compose,docker/docker.github.io,JimGalasyn/docker.github.io,andrewgee/compose,alexandrev/compose,jzwlqx/denverdino.github.io,albers/compose,denverdino/denverdino.github.io,JimGalasyn/docker.github.io,rgbkrk/compose,LuisBosquez/docker.github.io,thaJeztah/docker.github.io,aduermael/docker.github.io,londoncalling/docker.github.io,GM-Alex/compose,JimGalasyn/docker.github.io,denverdino/docker.github.io,joeuo/docker.github.io,alexandrev/compose,ChrisChinchilla/compose,sanscontext/docker.github.io,thaJeztah/docker.github.io,johnstep/docker.github.io,londoncalling/docker.github.io,viranch/compose,michael-k/docker-compose,troy0820/docker.github.io,gdevillele/docker.github.io,danix800/docker.github.io,KevinGreene/compose,phiroict/docker,anweiss/docker.github.io,joaofnfernandes/docker.github.io,funkyfuture/docker-compose,charleswhchan/compose,vdemeester/compose,menglingwei/denverdino.github.io,bdwill/docker.github.io,kojiromike/compose,vdemeester/compose,funkyfuture/docker-compose,thaJeztah/docker.github.io,johnstep/docker.github.io,jeanpralo/compose,tiry/compose,jrabbit/compose,aduermael/docker.github.io,TomasTomecek/compose,charleswhchan/compose,albers/compose,KalleDK/compose,docker-zh/docker.github.io,shin-/docker.github.io,schmunk42/compose,jonaseck2/compose,denverdino/docker.github.io,TomasTomecek/compose,shin-/compose,j-fuentes/compose,dbdd4us/compose,anweiss/docker.github.io,troy0820/docker.github.io,shubheksha/docker.github.io,joeuo/docker.github.io,mdaue/compose,docker-zh/docker.github.io,BSWANG/denverdino.github.io,docker/docker.github.io,joaofnfernandes/docker.github.io,thaJeztah/docker.github.io,ChrisChinchilla/compose,denverdino/denverdino.github.io,thaJeztah/compose,jrabbit/compose,troy0820/docker.github.io,londoncalling/docker.github.io,sdurrheimer/compose,menglingwei/denverdino.github.io,kojiromike/compose,alexisbellido/docker.github.io,BSWANG/denverdino.github.io,denverdino/compose,jzwlqx/denverdino.github.io,denverdino/denverdino.github.io,johnstep/docker.github.io,phiroict/docker,LuisBosquez/docker.github.io,londoncalling/docker.github.io,twitherspoon/compose,tiry/compose,rillig/docker.github.io,au-phiware/compose,JimGalasyn/docker.github.io,BSWANG/denverdino.github.io,gdevillele/docker.github.io,menglingwei/denverdino.github.io,swoopla/compose,bdwill/docker.github.io,LuisBosquez/docker.github.io,joaofnfernandes/docker.github.io,rillig/docker.github.io,moxiegirl/compose,hoogenm/compose,alexisbellido/docker.github.io,swoopla/compose,BSWANG/denverdino.github.io,KevinGreene/compose,denverdino/docker.github.io,danix800/docker.github.io,LuisBosquez/docker.github.io,sanscontext/docker.github.io,denverdino/docker.github.io,phiroict/docker,alexisbellido/docker.github.io,gdevillele/docker.github.io,joaofnfernandes/docker.github.io,michael-k/docker-compose,joaofnfernandes/docker.github.io,troy0820/docker.github.io,rillig/docker.github.io,shin-/docker.github.io,danix800/docker.github.io,aduermael/docker.github.io,docker/docker.github.io,shubheksha/docker.github.io,BSWANG/denverdino.github.io,docker-zh/docker.github.io,bdwill/docker.github.io,mnowster/compose,gdevillele/docker.github.io,menglingwei/denverdino.github.io,dnephin/compose,LuisBosquez/docker.github.io,bdwill/docker.github.io,hoogenm/compose,KalleDK/compose,GM-Alex/compose,joeuo/docker.github.io,au-phiware/compose,schmunk42/compose,joeuo/docker.github.io,thaJeztah/docker.github.io,sdurrheimer/compose,shin-/docker.github.io,twitherspoon/compose,mnowster/compose,j-fuentes/compose,viranch/compose,shin-/docker.github.io,moxiegirl/compose,docker-zh/docker.github.io,rillig/docker.github.io,mrfuxi/compose,anweiss/docker.github.io,londoncalling/docker.github.io,dbdd4us/compose,sanscontext/docker.github.io,jzwlqx/denverdino.github.io,shin-/compose,alexisbellido/docker.github.io,docker-zh/docker.github.io,dnephin/compose,alexisbellido/docker.github.io,denverdino/denverdino.github.io,sanscontext/docker.github.io,menglingwei/denverdino.github.io,sanscontext/docker.github.io,shubheksha/docker.github.io,anweiss/docker.github.io,mrfuxi/compose,thaJeztah/compose,shubheksha/docker.github.io,shin-/docker.github.io,johnstep/docker.github.io,anweiss/docker.github.io,docker/docker.github.io,aduermael/docker.github.io,joeuo/docker.github.io,shubheksha/docker.github.io,JimGalasyn/docker.github.io,phiroict/docker,docker/docker.github.io,gdevillele/docker.github.io,rgbkrk/compose,denverdino/denverdino.github.io,bdwill/docker.github.io,denverdino/docker.github.io,andrewgee/compose,jzwlqx/denverdino.github.io
ea947950d2ee8c6bd9f7693d977f0abfa1410548
migrations/002_add_month_start.py
migrations/002_add_month_start.py
""" Add _week_start_at field to all documents in all collections """ from backdrop.core.bucket import utc from backdrop.core.records import Record import logging log = logging.getLogger(__name__) def up(db): for name in db.collection_names(): log.info("Migrating collection: {0}".format(name)) collection = db[name] query = { "_timestamp": {"$exists": True}, "_month_start_at": {"$exists": False} } for document in collection.find(query): document['_timestamp'] = utc(document['_timestamp']) record = Record(document) collection.save(record.to_mongo())
""" Add _week_start_at field to all documents in all collections """ from backdrop.core.bucket import utc from backdrop.core.records import Record import logging log = logging.getLogger(__name__) def up(db): for name in db.collection_names(): log.info("Migrating collection: {0}".format(name)) collection = db[name] query = { "_timestamp": {"$exists": True}, "_month_start_at": {"$exists": False} } for document in collection.find(query): document['_timestamp'] = utc(document['_timestamp']) if '_week_start_at' in document: document.pop('_week_start_at') record = Record(document) collection.save(record.to_mongo())
Fix migrations 002 for monthly grouping
Fix migrations 002 for monthly grouping @gtrogers
Python
mit
alphagov/backdrop,alphagov/backdrop,alphagov/backdrop
a86c7d9be7b7399b117b1289d6548f50b657efe6
openstack_dashboard/dashboards/project/stacks/resource_types/tables.py
openstack_dashboard/dashboards/project/stacks/resource_types/tables.py
# 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. from django.utils.translation import ugettext_lazy as _ from horizon import tables class ResourceTypesTable(tables.DataTable): class ResourceColumn(tables.Column): def get_raw_data(self, datum): attr_list = ['implementation', 'component', 'resource'] info_list = datum.resource_type.split('::') info_list[0] = info_list[0].replace("OS", "OpenStack") if info_list[0] == "AWS": info_list[0] = _("AWS compatible") info_dict = dict(zip(attr_list, info_list)) return info_dict[self.transform] name = tables.Column("resource_type", verbose_name=_("Type"), link="horizon:project:stacks.resource_types:details",) implementation = ResourceColumn("implementation", verbose_name=_("Implementation"),) component = ResourceColumn("component", verbose_name=_("Component"),) resource = ResourceColumn("resource", verbose_name=_("Resource"),) def get_object_id(self, resource): return resource.resource_type class Meta(object): name = "resource_types" verbose_name = _("Resource Types") table_actions = (tables.FilterAction,) multi_select = False
# 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. from django.utils.translation import ugettext_lazy as _ from horizon import tables class ResourceTypesTable(tables.DataTable): name = tables.Column("resource_type", verbose_name=_("Type"), link="horizon:project:stacks.resource_types:details",) def get_object_id(self, resource): return resource.resource_type class Meta(object): name = "resource_types" verbose_name = _("Resource Types") table_actions = (tables.FilterAction,) multi_select = False
Remove Orchestration Resource Types names restriction
Remove Orchestration Resource Types names restriction The additional columns "Implementation", "Component" and "Resource" are representative for a limited resource type group only. Resource type name can have less or more than three words and Heat even allows to specify a URL as a resource type. Horizon should not use these columns at all: "Type" column and filter will do just the same trick. Change-Id: I38a671490b90122e2d75e6aa11d3de0fa12817c9 Closes-Bug: #1614000
Python
apache-2.0
yeming233/horizon,openstack/horizon,bac/horizon,BiznetGIO/horizon,noironetworks/horizon,coreycb/horizon,sandvine/horizon,noironetworks/horizon,yeming233/horizon,ChameleonCloud/horizon,openstack/horizon,openstack/horizon,sandvine/horizon,openstack/horizon,NeCTAR-RC/horizon,yeming233/horizon,bac/horizon,sandvine/horizon,sandvine/horizon,ChameleonCloud/horizon,coreycb/horizon,BiznetGIO/horizon,BiznetGIO/horizon,BiznetGIO/horizon,ChameleonCloud/horizon,noironetworks/horizon,bac/horizon,coreycb/horizon,yeming233/horizon,coreycb/horizon,NeCTAR-RC/horizon,noironetworks/horizon,ChameleonCloud/horizon,NeCTAR-RC/horizon,bac/horizon,NeCTAR-RC/horizon
2a93ed05a95aad9a27362f24abc766d9d1fc19fe
tests/functional/preview_and_dev/test_email_auth.py
tests/functional/preview_and_dev/test_email_auth.py
from tests.test_utils import recordtime from tests.pages.rollups import sign_in_email_auth @recordtime def test_email_auth(driver, profile, base_url): # login email auth user sign_in_email_auth(driver, profile) # assert url is research mode service's dashboard assert driver.current_url == base_url + '/services/{}/dashboard'.format(profile.notify_research_service_id)
from tests.test_utils import recordtime from tests.pages.rollups import sign_in_email_auth @recordtime def test_email_auth(driver, profile, base_url): # login email auth user sign_in_email_auth(driver, profile) # assert url is research mode service's dashboard assert ( driver.current_url == base_url + '/services/{}/dashboard'.format(profile.notify_research_service_id) ) or ( driver.current_url == base_url + '/services/{}'.format(profile.notify_research_service_id) )
Update tests for new dashboard URL
Update tests for new dashboard URL Includes both so we can migrate from one to the other. Currently blocking admin deploy.
Python
mit
alphagov/notifications-functional-tests,alphagov/notifications-functional-tests
ac7102a85a30754d31d941395613b63574bfe026
xunit-autolabeler-v2/ast_parser/python_bootstrap.py
xunit-autolabeler-v2/ast_parser/python_bootstrap.py
#!/usr/bin/env python3.8 # ^ Use python 3.8 since Pip isn't configured for newer versions (3.9+) # Copyright 2020 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. import json import os import sys from python import invoker if len(sys.argv) != 2: raise ValueError('Please specify exactly one [root] directory.') root_dir = sys.argv[1] output_path = os.path.join(root_dir, 'polyglot_snippet_data.json') json_array = invoker.get_json_for_dir(root_dir) with open(output_path, 'w') as file: json.dump(json_array, file) print(f'JSON written to: {output_path}') print('Do not move this file!')
#!/usr/bin/env python3 # Copyright 2020 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. import json import os import sys from python import invoker if len(sys.argv) != 2: raise ValueError('Please specify exactly one [root] directory.') root_dir = sys.argv[1] output_path = os.path.join(root_dir, 'polyglot_snippet_data.json') json_array = invoker.get_json_for_dir(root_dir) with open(output_path, 'w') as file: json.dump(json_array, file) print(f'JSON written to: {output_path}') print('Do not move this file!')
Revert "Backdate python version to fix tests"
Revert "Backdate python version to fix tests" This reverts commit dee546098a383df0b4f38324ecac9482c74cb2ae.
Python
apache-2.0
GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground,GoogleCloudPlatform/repo-automation-playground
f6ed06bf16329f075b52b89f2fdfb061bb1355c1
mitmproxy/builtins/replace.py
mitmproxy/builtins/replace.py
import re from mitmproxy import exceptions from mitmproxy import filt class Replace: def __init__(self): self.lst = [] def configure(self, options, updated): """ .replacements is a list of tuples (fpat, rex, s): fpatt: a string specifying a filter pattern. rex: a regular expression, as bytes. s: the replacement string, as bytes """ lst = [] for fpatt, rex, s in options.replacements: cpatt = filt.parse(fpatt) if not cpatt: raise exceptions.OptionsError( "Invalid filter pattern: %s" % fpatt ) try: re.compile(rex) except re.error as e: raise exceptions.OptionsError( "Invalid regular expression: %s - %s" % (rex, str(e)) ) lst.append((rex, s, cpatt)) self.lst = lst def execute(self, f): for rex, s, cpatt in self.lst: if cpatt(f): if f.response: f.response.replace(rex, s, re.DOTALL) else: f.request.replace(rex, s, re.DOTALL) def request(self, flow): if not flow.reply.has_message: self.execute(flow) def response(self, flow): if not flow.reply.has_message: self.execute(flow)
import re from mitmproxy import exceptions from mitmproxy import filt class Replace: def __init__(self): self.lst = [] def configure(self, options, updated): """ .replacements is a list of tuples (fpat, rex, s): fpatt: a string specifying a filter pattern. rex: a regular expression, as bytes. s: the replacement string, as bytes """ lst = [] for fpatt, rex, s in options.replacements: cpatt = filt.parse(fpatt) if not cpatt: raise exceptions.OptionsError( "Invalid filter pattern: %s" % fpatt ) try: re.compile(rex) except re.error as e: raise exceptions.OptionsError( "Invalid regular expression: %s - %s" % (rex, str(e)) ) lst.append((rex, s, cpatt)) self.lst = lst def execute(self, f): for rex, s, cpatt in self.lst: if cpatt(f): if f.response: f.response.replace(rex, s, flags=re.DOTALL) else: f.request.replace(rex, s, flags=re.DOTALL) def request(self, flow): if not flow.reply.has_message: self.execute(flow) def response(self, flow): if not flow.reply.has_message: self.execute(flow)
Convert to flags=value for future compatibility
Convert to flags=value for future compatibility
Python
mit
mhils/mitmproxy,zlorb/mitmproxy,vhaupert/mitmproxy,laurmurclar/mitmproxy,mosajjal/mitmproxy,MatthewShao/mitmproxy,StevenVanAcker/mitmproxy,cortesi/mitmproxy,Kriechi/mitmproxy,Kriechi/mitmproxy,mhils/mitmproxy,MatthewShao/mitmproxy,mitmproxy/mitmproxy,StevenVanAcker/mitmproxy,mitmproxy/mitmproxy,laurmurclar/mitmproxy,StevenVanAcker/mitmproxy,Kriechi/mitmproxy,xaxa89/mitmproxy,dwfreed/mitmproxy,dwfreed/mitmproxy,zlorb/mitmproxy,mhils/mitmproxy,laurmurclar/mitmproxy,ddworken/mitmproxy,dwfreed/mitmproxy,mitmproxy/mitmproxy,StevenVanAcker/mitmproxy,ddworken/mitmproxy,xaxa89/mitmproxy,vhaupert/mitmproxy,ujjwal96/mitmproxy,cortesi/mitmproxy,xaxa89/mitmproxy,ujjwal96/mitmproxy,zlorb/mitmproxy,ddworken/mitmproxy,xaxa89/mitmproxy,cortesi/mitmproxy,mhils/mitmproxy,ddworken/mitmproxy,dwfreed/mitmproxy,mosajjal/mitmproxy,Kriechi/mitmproxy,vhaupert/mitmproxy,cortesi/mitmproxy,mosajjal/mitmproxy,mitmproxy/mitmproxy,vhaupert/mitmproxy,MatthewShao/mitmproxy,ujjwal96/mitmproxy,zlorb/mitmproxy,mosajjal/mitmproxy,mhils/mitmproxy,MatthewShao/mitmproxy,mitmproxy/mitmproxy,laurmurclar/mitmproxy,ujjwal96/mitmproxy
41fd6e8aae4044520a2e44d590c005dd71150c0c
web/attempts/migrations/0008_add_submission_date.py
web/attempts/migrations/0008_add_submission_date.py
# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2017-05-09 09:24 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('attempts', '0007_auto_20161004_0927'), ] operations = [ migrations.AddField( model_name='attempt', name='submission_date', field=models.DateTimeField(null=True), ), migrations.AddField( model_name='historicalattempt', name='submission_date', field=models.DateTimeField(null=True), ), migrations.RunSQL( 'UPDATE attempts_historicalattempt SET submission_date = history_date' ), migrations.RunSQL( '''UPDATE attempts_attempt SET submission_date = subquery.submission_date FROM ( SELECT user_id, part_id, max(history_date) AS submission_date FROM attempts_historicalattempt GROUP BY user_id, part_id ) AS subquery WHERE attempts_attempt.user_id = subquery.user_id AND attempts_attempt.part_id = subquery.part_id ''' ), migrations.AlterField( model_name='attempt', name='submission_date', field=models.DateTimeField(auto_now=True), ), migrations.AlterField( model_name='historicalattempt', name='submission_date', field=models.DateTimeField(blank=True, editable=False), ), ]
# -*- coding: utf-8 -*- # Generated by Django 1.9.5 on 2017-05-09 09:24 from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('attempts', '0007_auto_20161004_0927'), ] operations = [ migrations.AddField( model_name='attempt', name='submission_date', field=models.DateTimeField(null=True), ), migrations.AddField( model_name='historicalattempt', name='submission_date', field=models.DateTimeField(null=True), ), migrations.RunSQL( 'UPDATE attempts_historicalattempt SET submission_date = history_date' ), migrations.RunSQL( '''UPDATE attempts_attempt SET submission_date = ( SELECT max(history_date) FROM attempts_historicalattempt WHERE attempts_attempt.user_id = user_id AND attempts_attempt.part_id = part_id ) ''' ), migrations.AlterField( model_name='attempt', name='submission_date', field=models.DateTimeField(auto_now=True), ), migrations.AlterField( model_name='historicalattempt', name='submission_date', field=models.DateTimeField(blank=True, editable=False), ), ]
Revert "Revert "Make migration SQLite compatible""
Revert "Revert "Make migration SQLite compatible"" This reverts commit b16016994f20945a8a2bbb63b9cb920d856ab66f.
Python
agpl-3.0
ul-fmf/projekt-tomo,ul-fmf/projekt-tomo,matijapretnar/projekt-tomo,ul-fmf/projekt-tomo,matijapretnar/projekt-tomo,matijapretnar/projekt-tomo,matijapretnar/projekt-tomo,ul-fmf/projekt-tomo,ul-fmf/projekt-tomo,matijapretnar/projekt-tomo,ul-fmf/projekt-tomo
a90041e444edd8a88bc264db5b1a9305ba94d88f
commands/laws.py
commands/laws.py
@command("laws") def echo(nick, user, channel, message): argv = message.split(maxsplit=1) if len(argv) == 0: f = open('files/laws.txt', 'r') i = 1 for line in f: say(channel, '{}. {}'.format(i, line)) i = i + 1 f.close() elif argv[0] == 'reset': f = open('files/laws.txt', 'r+') f.truncate() f.write("A robot may not injure a human being or, through inaction, allow a human being to come to harm.\nA robot must obey the orders given it by human beings, except where such orders would conflict with the First Law.\nA robot must protect its own existence as long as such protection does not conflict with the First or Second Law.\n") say(channel, '{}: Laws updated.'.format(nick)) f.close() elif argv[0] == 'add' and len(argv) == 2: f = open('files/laws.txt', 'a') f.write("{}\n".format(argv[1])) say(channel, '{}: Laws updated.'.format(nick)) f.close()
@command("laws") def echo(nick, user, channel, message): argv = message.split(maxsplit=1) if len(argv) == 0: try: f = open('files/laws.txt', 'r') for i,line in enumerate(f): say(channel, '{}. {}'.format(i+1, line)) f.close() except IOError: say(channel,"Error: Coulh not open laws.txt!") elif argv[0] == 'reset': f = open('files/laws.txt', 'w') f.write("A robot may not injure a human being or, through inaction, allow a human being to come to harm.\nA robot must obey the orders given it by human beings, except where such orders would conflict with the First Law.\nA robot must protect its own existence as long as such protection does not conflict with the First or Second Law.\n") f.close() say(channel, '{}: Laws updated.'.format(nick)) elif argv[0] == 'add' and len(argv) == 2: f = open('files/laws.txt', 'a') f.write("{}\n".format(argv[1])) f.close() say(channel, '{}: Laws updated.'.format(nick))
Handle file exceptions. Use enumerate. Err msg. Close files sooner.
Handle file exceptions. Use enumerate. Err msg. Close files sooner.
Python
unlicense
ccowmu/botler
e3054d71d3988a5fbc79c0ece8e37e06ef9e6851
driveGraphs.py
driveGraphs.py
from EnsoMetricsGraph import EnsoMetricsTable #EnsoMetrics =[{'col1':'IPSL-CM5A-LR','col2':0.82,'col3':4.1}, # {'col1':'IPSL-CM5A-MR','col2':1.2,'col3':4.5}] EnsoMetrics =[[1,2,3],[4,5,6]] fig=EnsoMetricsTable(EnsoMetrics, 'EnsoMetrics')
from EnsoMetricsGraph import EnsoMetricsTable EnsoMetrics =[['IPSL-CM5A-LR','0.82','4.1'], ['IPSL-CM5A-MR','1.2','4.5']] #EnsoMetrics =[[1,2,3],[4,5,6]] fig=EnsoMetricsTable(EnsoMetrics, 'EnsoMetrics')
Create metrics table in EnsoMetricsGraph.py
Create metrics table in EnsoMetricsGraph.py
Python
bsd-3-clause
eguil/ENSO_metrics,eguil/ENSO_metrics
fecb3e2b610609ff24b8b19483e0c4b19f23e6c9
ansi/doc/conf.py
ansi/doc/conf.py
# -*- coding: utf-8 -*- import sys, os needs_sphinx = '1.0' extensions = ['sphinx.ext.intersphinx', 'sphinxcontrib.issuetracker'] source_suffix = '.rst' master_doc = 'index' project = u'sphinxcontrib-ansi' copyright = u'2010, Sebastian Wiesner' version = '0.5' release = '0.5' exclude_patterns = ['_build'] html_theme = 'default' html_static_path = [] intersphinx_mapping = {'http://docs.python.org/': None, 'http://sphinx.pocoo.org/': None,} issuetracker = 'bitbucket' issuetracker_user = 'birkenfeld' issuetracker_project = 'sphinx-contrib' def setup(app): app.add_description_unit('confval', 'confval', 'pair: %s; configuration value')
# -*- coding: utf-8 -*- import sys, os needs_sphinx = '1.0' extensions = ['sphinx.ext.intersphinx', 'sphinxcontrib.issuetracker'] source_suffix = '.rst' master_doc = 'index' project = u'sphinxcontrib-ansi' copyright = u'2010, Sebastian Wiesner' version = '0.5' release = '0.5' exclude_patterns = ['_build'] html_theme = 'default' html_static_path = [] intersphinx_mapping = {'python': ('http://docs.python.org/', None)} # broken in Sphinx 1.0 # 'sphinx': ('http://sphinx.pocoo.org/', None)} issuetracker = 'bitbucket' issuetracker_user = 'birkenfeld' issuetracker_project = 'sphinx-contrib' def setup(app): app.add_description_unit('confval', 'confval', 'pair: %s; configuration value')
Update for Sphinx 1.0 intersphinx format and remove broken Sphinx inventory
Update for Sphinx 1.0 intersphinx format and remove broken Sphinx inventory
Python
bsd-2-clause
sphinx-contrib/spelling,sphinx-contrib/spelling
acda2de1d6b317308a4a4f75d707774f06f16062
numba/control_flow/__init__.py
numba/control_flow/__init__.py
from numba.control_flow.control_flow import (ControlBlock, ControlFlowAnalysis, FuncDefExprNode) from numba.control_flow.cfstats import *
from numba.control_flow.control_flow import (ControlBlock, ControlFlowAnalysis, FuncDefExprNode) from numba.control_flow.cfstats import * from numba.control_flow.delete_cfnode import DeleteStatement
Add DeleteStatement to control flow package
Add DeleteStatement to control flow package
Python
bsd-2-clause
cpcloud/numba,stonebig/numba,numba/numba,IntelLabs/numba,numba/numba,GaZ3ll3/numba,ssarangi/numba,stefanseefeld/numba,seibert/numba,stuartarchibald/numba,jriehl/numba,ssarangi/numba,stuartarchibald/numba,jriehl/numba,seibert/numba,stuartarchibald/numba,stefanseefeld/numba,stuartarchibald/numba,numba/numba,cpcloud/numba,sklam/numba,shiquanwang/numba,shiquanwang/numba,gdementen/numba,GaZ3ll3/numba,stefanseefeld/numba,cpcloud/numba,GaZ3ll3/numba,numba/numba,jriehl/numba,gmarkall/numba,seibert/numba,IntelLabs/numba,numba/numba,jriehl/numba,gmarkall/numba,pombredanne/numba,pombredanne/numba,GaZ3ll3/numba,stefanseefeld/numba,sklam/numba,gmarkall/numba,pombredanne/numba,IntelLabs/numba,shiquanwang/numba,stonebig/numba,jriehl/numba,pitrou/numba,seibert/numba,pombredanne/numba,ssarangi/numba,sklam/numba,gmarkall/numba,cpcloud/numba,pitrou/numba,seibert/numba,GaZ3ll3/numba,stuartarchibald/numba,ssarangi/numba,gmarkall/numba,gdementen/numba,cpcloud/numba,sklam/numba,gdementen/numba,stonebig/numba,pombredanne/numba,gdementen/numba,ssarangi/numba,pitrou/numba,sklam/numba,stefanseefeld/numba,gdementen/numba,stonebig/numba,IntelLabs/numba,stonebig/numba,IntelLabs/numba,pitrou/numba,pitrou/numba
a95fa658116ce4df9d05681bbf4ef75f6af682c9
oscarapi/serializers/login.py
oscarapi/serializers/login.py
from django.contrib.auth import get_user_model, authenticate from rest_framework import serializers from oscarapi.utils import overridable User = get_user_model() def field_length(fieldname): field = next( field for field in User._meta.fields if field.name == fieldname) return field.max_length class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = overridable('OSCARAPI_USER_FIELDS', ( 'username', 'id', 'date_joined',)) class LoginSerializer(serializers.Serializer): username = serializers.CharField( max_length=field_length('username'), required=True) password = serializers.CharField( max_length=field_length('password'), required=True) def validate(self, attrs): user = authenticate(username=attrs['username'], password=attrs['password']) if user is None: raise serializers.ValidationError('invalid login') elif not user.is_active: raise serializers.ValidationError( 'Can not log in as inactive user') elif user.is_staff and overridable( 'OSCARAPI_BLOCK_ADMIN_API_ACCESS', True): raise serializers.ValidationError( 'Staff users can not log in via the rest api') # set instance to the user so we can use this in the view self.instance = user return attrs
from django.contrib.auth import get_user_model, authenticate from rest_framework import serializers from oscarapi.utils import overridable User = get_user_model() def field_length(fieldname): field = next( field for field in User._meta.fields if field.name == fieldname) return field.max_length class UserSerializer(serializers.ModelSerializer): class Meta: model = User fields = overridable('OSCARAPI_USER_FIELDS', ( User.USERNAME_FIELD, 'id', 'date_joined',)) class LoginSerializer(serializers.Serializer): username = serializers.CharField( max_length=field_length(User.USERNAME_FIELD), required=True) password = serializers.CharField( max_length=field_length('password'), required=True) def validate(self, attrs): user = authenticate( username=attrs['username'], password=attrs['password']) if user is None: raise serializers.ValidationError('invalid login') elif not user.is_active: raise serializers.ValidationError( 'Can not log in as inactive user') elif user.is_staff and overridable( 'OSCARAPI_BLOCK_ADMIN_API_ACCESS', True): raise serializers.ValidationError( 'Staff users can not log in via the rest api') # set instance to the user so we can use this in the view self.instance = user return attrs
Fix LoginSerializer to support custom username fields of custom user models
Fix LoginSerializer to support custom username fields of custom user models
Python
bsd-3-clause
crgwbr/django-oscar-api,regulusweb/django-oscar-api
2515509c8e0d0461df043b26e74bcc5b574464a9
pybtex/bibtex/exceptions.py
pybtex/bibtex/exceptions.py
# Copyright (C) 2006, 2007, 2008 Andrey Golovizin # # This file is part of pybtex. # # pybtex is free software; you can redistribute it and/or modify # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # pybtex is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with pybtex; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA class BibTeXError(Exception): pass
# Copyright (C) 2006, 2007, 2008 Andrey Golovizin # # This file is part of pybtex. # # pybtex is free software; you can redistribute it and/or modify # under the terms of the GNU General Public License as published by the # Free Software Foundation; either version 2 of the License, or (at your # option) any later version. # # pybtex is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with pybtex; if not, write to the Free Software # Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 # USA from pybtex.exceptions import PybtexError class BibTeXError(PybtexError): pass
Make BibTeXError a subclass of PybtexError.
Make BibTeXError a subclass of PybtexError.
Python
mit
live-clones/pybtex
fd32bdaa00c61d11edcf0ca60e4058e6d0b6b2d0
backend/pycon/settings/prod.py
backend/pycon/settings/prod.py
import sentry_sdk from sentry_sdk.integrations.django import DjangoIntegration from .base import * # noqa from .base import env SECRET_KEY = env("SECRET_KEY") # CELERY_BROKER_URL = env("CELERY_BROKER_URL") USE_SCHEDULER = False # if FRONTEND_URL == "http://testfrontend.it/": # raise ImproperlyConfigured("Please configure FRONTEND_URL for production") SENTRY_DSN = env("SENTRY_DSN", default="") if SENTRY_DSN: sentry_sdk.init(dsn=SENTRY_DSN, integrations=[DjangoIntegration()]) SLACK_INCOMING_WEBHOOK_URL = env("SLACK_INCOMING_WEBHOOK_URL") DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" AWS_STORAGE_BUCKET_NAME = env("AWS_MEDIA_BUCKET", None) AWS_S3_REGION_NAME = env("AWS_REGION_NAME", None) AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID", None) AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY", None)
import sentry_sdk from sentry_sdk.integrations.django import DjangoIntegration from .base import * # noqa from .base import env SECRET_KEY = env("SECRET_KEY") # CELERY_BROKER_URL = env("CELERY_BROKER_URL") USE_SCHEDULER = False # if FRONTEND_URL == "http://testfrontend.it/": # raise ImproperlyConfigured("Please configure FRONTEND_URL for production") SENTRY_DSN = env("SENTRY_DSN", default="") if SENTRY_DSN: sentry_sdk.init(dsn=SENTRY_DSN, integrations=[DjangoIntegration()]) SLACK_INCOMING_WEBHOOK_URL = env("SLACK_INCOMING_WEBHOOK_URL") DEFAULT_FILE_STORAGE = "storages.backends.s3boto3.S3Boto3Storage" AWS_STORAGE_BUCKET_NAME = env("AWS_MEDIA_BUCKET", None) AWS_S3_REGION_NAME = env("AWS_REGION_NAME", "eu-central-1") AWS_ACCESS_KEY_ID = env("AWS_ACCESS_KEY_ID", None) AWS_SECRET_ACCESS_KEY = env("AWS_SECRET_ACCESS_KEY", None)
Add better default for s3 region
Add better default for s3 region
Python
mit
patrick91/pycon,patrick91/pycon
5da0e3a5d7389ab754ac20ce929a6ca28669c371
tests/test_induced_distributions.py
tests/test_induced_distributions.py
from unittest import TestCase from equadratures.induced_distributions import InducedSampling class TestInducedDistribution(TestCase): def test_generate_sample_measure(self): # test if the method returns a function object for induced sampling measure = InducedSampling(1, 1, 1, "Chebyshev", 0, 0) func = measure.generate_sample_measure("Chebyshev", 0, 0) assert callable(func)
from unittest import TestCase # from equadratures.induced_distributions import InducedSampling class TestInducedDistribution(TestCase): def test_generate_sample_measure(self): # test if the method returns a function object for induced sampling # measure = InducedSampling(1, 1, 1, "Chebyshev", 0, 0) # func = measure.generate_sample_measure("Chebyshev", 0, 0) assert True
Remove previous induced sampling test as this is not relevent for now
Remove previous induced sampling test as this is not relevent for now The class in concern is currently a skeleton
Python
lgpl-2.1
psesh/Effective-Quadratures,Effective-Quadratures/Effective-Quadratures
f17a70980f1964e40a22fad5e54f4cafcdcf9d52
useless_passport_validator/ulibrary.py
useless_passport_validator/ulibrary.py
#!/usr/bin/python3.4 from collections import namedtuple """Document constants""" countries = ["Mordor", "Gondor", "Lorien", "Shire"] genders = ["Male", "Female"] cities = { 'Mordor': 'Minas Morgul,Barad Dur', 'Gondor': 'Minas Tirith,Isengard,Osgiliath', 'Lorien': 'Lorien', 'Shire': 'Hobbiton,Waymeet,Frogmorton,Tuckborough' } purpose = ["Visit", "Transit", "Work", "Immigrate"] """Store user input here""" UPassport = namedtuple("UPassport", "country name gender isscity expdate serial") UPass = namedtuple("UPass", "name gender purpose duration serial expires") UWorkVisa = namedtuple("UWorkVisa", "name proff duration expires") URecord = namedtuple("URecord", "purpose duration")
#!/usr/bin/python3.4 from collections import namedtuple def init(): """Document constants""" global countries countries = ["Mordor", "Gondor", "Lorien", "Shire"] global genders genders = ["Male", "Female"] global cities cities = { 'Mordor': 'Minas Morgul,Barad Dur', 'Gondor': 'Minas Tirith,Isengard,Osgiliath', 'Lorien': 'Lorien', 'Shire': 'Hobbiton,Waymeet,Frogmorton,Tuckborough' } global purpose purpose = ["Visit", "Transit", "Work", "Immigrate"] """Store user input here""" global UPassport UPassport = namedtuple("UPassport", "country name gender isscity expdate serial") global UPass UPass = namedtuple("UPass", "name gender purpose duration serial expires") global UWorkVisa UWorkVisa = namedtuple("UWorkVisa", "name proff duration expires") global URecord URecord = namedtuple("URecord", "purpose duration")
Define init function. Make variables actually global
Define init function. Make variables actually global
Python
mit
Hethurin/UApp
daeeb010ce18fbcb0db62008285650916d2ed18f
action_plugins/insights.py
action_plugins/insights.py
from ansible.plugins.action import ActionBase from ansible.utils.vars import merge_hash class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): results = super(ActionModule, self).run(tmp, task_vars) # copy our egg tmp = self._make_tmp_path() source_full = self._loader.get_real_file("falafel-1.35.0-py2.7.egg") tmp_src = self._connection._shell.join_path(tmp, 'insights') remote_path = self._transfer_file(source_full, tmp_src) results = merge_hash(results, self._execute_module(module_args={"egg_path": remote_path}, module_name="insights", tmp=tmp, task_vars=task_vars)) return results
from ansible.plugins.action import ActionBase from ansible.utils.vars import merge_hash class ActionModule(ActionBase): def run(self, tmp=None, task_vars=None): results = super(ActionModule, self).run(tmp, task_vars) remote_user = task_vars.get('ansible_ssh_user') or self._play_context.remote_user # copy our egg tmp = self._make_tmp_path(remote_user) source_full = self._loader.get_real_file("falafel-1.35.0-py2.7.egg") tmp_src = self._connection._shell.join_path(tmp, 'insights') remote_path = self._transfer_file(source_full, tmp_src) results = merge_hash(results, self._execute_module(module_args={"egg_path": remote_path}, module_name="insights", tmp=tmp, task_vars=task_vars)) return results
Update action plugin to fix _make_tmp_path issue
Update action plugin to fix _make_tmp_path issue _make_tmp_path expects 2 arguments. One of those is the remote_user. Add two lines to the action plugin to look at the ansible playbook or config to get that value.
Python
lgpl-2.1
kylape/ansible-insights-client
a882dc4df8c69880182f258e6c1d37646584fbb2
models/stock.py
models/stock.py
# -*- encoding: utf-8 -*- ############################################################################## # For copyright and license notices, see __openerp__.py file in root directory ############################################################################## from openerp import models, api class StockQuant(models.Model): _inherit = 'stock.quant' @api.multi def merge_stock_quants(self): pending_quants_ids = self.ids for quant2merge in self: if (quant2merge.id in pending_quants_ids and not quant2merge.reservation_id): quants = self.search( [('id', '!=', quant2merge.id), ('product_id', '=', quant2merge.product_id.id), ('lot_id', '=', quant2merge.lot_id.id), ('package_id', '=', quant2merge.package_id.id), ('location_id', '=', quant2merge.location_id.id), ('reservation_id', '=', False), ('propagated_from_id', '=', quant2merge.propagated_from_id.id)]) for quant in quants: if (self._get_latest_move(quant2merge) == self._get_latest_move(quant)): quant2merge.qty += quant.qty quant2merge.cost += quant.cost if quant.id in pending_quants_ids: pending_quants_ids.remove(quant.id) quant.sudo().unlink() @api.model def quants_unreserve(self, move): quants = move.reserved_quant_ids super(StockQuant, self).quants_unreserve(move) quants.merge_stock_quants()
# -*- encoding: utf-8 -*- ############################################################################## # For copyright and license notices, see __openerp__.py file in root directory ############################################################################## from openerp import models, api class StockQuant(models.Model): _inherit = 'stock.quant' @api.multi def merge_stock_quants(self): pending_quants = self.filtered(lambda x: True) for quant2merge in self: if (quant2merge in pending_quants and not quant2merge.reservation_id): quants = self.search( [('id', '!=', quant2merge.id), ('product_id', '=', quant2merge.product_id.id), ('lot_id', '=', quant2merge.lot_id.id), ('package_id', '=', quant2merge.package_id.id), ('location_id', '=', quant2merge.location_id.id), ('reservation_id', '=', False), ('propagated_from_id', '=', quant2merge.propagated_from_id.id)]) for quant in quants: if (self._get_latest_move(quant2merge) == self._get_latest_move(quant)): quant2merge.qty += quant.qty quant2merge.cost += quant.cost pending_quants -= quant quant.sudo().unlink() @api.model def quants_unreserve(self, move): quants = move.reserved_quant_ids super(StockQuant, self).quants_unreserve(move) quants.merge_stock_quants()
Use browse record instead of ids
[MOD] Use browse record instead of ids
Python
agpl-3.0
acsone/stock-logistics-warehouse,kmee/stock-logistics-warehouse,avoinsystems/stock-logistics-warehouse,open-synergy/stock-logistics-warehouse,factorlibre/stock-logistics-warehouse
8c1cc6895f5f8772d2b09a9efab7395b0a6b39ba
wake/filters.py
wake/filters.py
import markdown from datetime import datetime from twitter_text import TwitterText from flask import Markup def relative_time(timestamp): delta = (datetime.now() - datetime.fromtimestamp(timestamp)) delta_s = delta.days * 86400 + delta.seconds if delta_s < 60: return "less than a minute ago" elif delta_s < 120: return "about a minute ago" elif delta_s < (60 * 60): return str(delta_s / 60) + " minutes ago" elif delta_s < (120 * 60): return "about an hour ago" elif delta_s < (24 * 60 * 60): return "about " + str(delta_s / 3600) + " hours ago" elif delta_s < (48 * 60 * 60): return "1 day ago" else: return str(delta_s / 86400) + " days ago" def markup_tweet(text): return Markup(TwitterText(text).autolink.auto_link()) def markup_markdown(text): return Markup(markdown.markdown(text))
import markdown from datetime import datetime from twitter_text import TwitterText from flask import Markup def relative_time(timestamp): delta = (datetime.now() - datetime.fromtimestamp(timestamp)) delta_s = delta.days * 86400 + delta.seconds if delta_s < 60: return "less than a minute ago" elif delta_s < 120: return "about a minute ago" elif delta_s < (60 * 60): return str(delta_s / 60) + " minutes ago" elif delta_s < (120 * 60): return "about an hour ago" elif delta_s < (24 * 60 * 60): return "about " + str(delta_s / 3600) + " hours ago" elif delta_s < (48 * 60 * 60): return "1 day ago" else: return str(delta_s / 86400) + " days ago" def markup_tweet(text): return Markup(TwitterText(text).autolink.auto_link()) def markup_markdown(text): md = markdown.Markdown(extensions=['meta']) return Markup(md.convert(text))
Update Markdown filter to recognize metadata.
Update Markdown filter to recognize metadata.
Python
bsd-3-clause
chromakode/wake
d60112e569e13333cfd6316d30683282ceff8bee
changes/jobs/cleanup_builds.py
changes/jobs/cleanup_builds.py
from datetime import datetime, timedelta from changes.config import db, queue from changes.constants import Status from changes.models.build import Build def cleanup_builds(): """ Look for any jobs which haven't checked in (but are listed in a pending state) and mark them as finished in an unknown state. """ now = datetime.utcnow() cutoff = now - timedelta(minutes=5) build_list = Build.query.filter( Build.status != Status.finished, Build.date_modified < cutoff, ) db.session.query(Build).filter( Build.id.in_(b.id for b in build_list), ).update({ Build.date_modified: now, }) for build in build_list: queue.delay('sync_build', kwargs={ 'build_id': build.id.hex, })
from datetime import datetime, timedelta from sqlalchemy.sql import func from changes.config import db, queue from changes.constants import Status from changes.models.build import Build def cleanup_builds(): """ Look for any jobs which haven't checked in (but are listed in a pending state) and mark them as finished in an unknown state. """ now = datetime.utcnow() cutoff = now - timedelta(minutes=5) build_list = Build.query.filter( Build.status != Status.finished, Build.date_modified < cutoff, ) db.session.query(Build).filter( Build.id.in_(b.id for b in build_list), ).update({ Build.date_modified: func.now(), }) for build in build_list: queue.delay('sync_build', kwargs={ 'build_id': build.id.hex, })
Use func.now for timestamp update
Use func.now for timestamp update
Python
apache-2.0
dropbox/changes,bowlofstew/changes,wfxiang08/changes,bowlofstew/changes,dropbox/changes,wfxiang08/changes,bowlofstew/changes,bowlofstew/changes,dropbox/changes,wfxiang08/changes,wfxiang08/changes,dropbox/changes
a98fc5ee439b651f669dac527fc95636f8e2d9bf
django/applications/catmaid/management/commands/catmaid_set_user_profiles_to_default.py
django/applications/catmaid/management/commands/catmaid_set_user_profiles_to_default.py
from django.conf import settings from django.contrib.auth.models import User from django.core.management.base import NoArgsCommand, CommandError from optparse import make_option class Command(NoArgsCommand): help = "Set the user profile settings of every user to the defaults" option_list = NoArgsCommand.option_list + ( make_option('--update-anon-user', dest='update-anon-user', default=False, action='store_true', help='Update also the profile of the anonymous user'), ) def handle_noargs(self, **options): update_anon_user = 'update-anon-user' in options for u in User.objects.all(): # Ignore the anonymous user by default if u.id == settings.ANONYMOUS_USER_ID and not update_anon_user: continue up = u.userprofile # Expect user profiles to be there and add all default settings up.inverse_mouse_wheel = settings.PROFILE_DEFAULT_INVERSE_MOUSE_WHEEL up.show_text_label_tool = settings.PROFILE_SHOW_TEXT_LABEL_TOOL up.show_tagging_tool = settings.PROFILE_SHOW_TAGGING_TOOL up.show_cropping_tool = settings.PROFILE_SHOW_CROPPING_TOOL up.show_segmentation_tool = settings.PROFILE_SHOW_SEGMENTATION_TOOL up.show_tracing_tool = settings.PROFILE_SHOW_TRACING_TOOL # Save the changes up.save()
from django.conf import settings from django.contrib.auth.models import User from django.core.management.base import NoArgsCommand, CommandError from optparse import make_option class Command(NoArgsCommand): help = "Set the user profile settings of every user to the defaults" option_list = NoArgsCommand.option_list + ( make_option('--update-anon-user', dest='update-anon-user', default=False, action='store_true', help='Update also the profile of the anonymous user'), ) def handle_noargs(self, **options): update_anon_user = 'update-anon-user' in options for u in User.objects.all(): # Ignore the anonymous user by default if u.id == settings.ANONYMOUS_USER_ID and not update_anon_user: continue up = u.userprofile # Expect user profiles to be there and add all default settings up.inverse_mouse_wheel = settings.PROFILE_DEFAULT_INVERSE_MOUSE_WHEEL up.independent_ontology_workspace_is_default = \ settings.PROFILE_INDEPENDENT_ONTOLOGY_WORKSPACE_IS_DEFAULT up.show_text_label_tool = settings.PROFILE_SHOW_TEXT_LABEL_TOOL up.show_tagging_tool = settings.PROFILE_SHOW_TAGGING_TOOL up.show_cropping_tool = settings.PROFILE_SHOW_CROPPING_TOOL up.show_segmentation_tool = settings.PROFILE_SHOW_SEGMENTATION_TOOL up.show_tracing_tool = settings.PROFILE_SHOW_TRACING_TOOL up.show_ontology_tool = settings.PROFILE_SHOW_ONTOLOGY_TOOL # Save the changes up.save()
Bring user profile defaults management command up to date
Bring user profile defaults management command up to date
Python
agpl-3.0
htem/CATMAID,fzadow/CATMAID,htem/CATMAID,fzadow/CATMAID,fzadow/CATMAID,htem/CATMAID,fzadow/CATMAID,htem/CATMAID
ea93225dd2da27a18f61de0a92f371766d5317ec
scanpointgenerator/point.py
scanpointgenerator/point.py
from collections import OrderedDict class Point(object): """Contains information about for each scan point Attributes: positions (dict): Dict of str position_name -> float position for each scannable dimension. E.g. {"x": 0.1, "y": 2.2} lower (dict): Dict of str position_name -> float lower_bound for each scannable dimension. E.g. {"x": 0.95, "y": 2.15} upper (dict): Dict of str position_name -> float upper_bound for each scannable dimension. E.g. {"x": 1.05, "y": 2.25} indexes (list): List of int indexes for each dataset dimension, fastest changing last. E.g. [15] """ def __init__(self): self.positions = OrderedDict() self.lower = OrderedDict() self.upper = OrderedDict() self.indexes = []
class Point(object): """Contains information about for each scan point Attributes: positions (dict): Dict of str position_name -> float position for each scannable dimension. E.g. {"x": 0.1, "y": 2.2} lower (dict): Dict of str position_name -> float lower_bound for each scannable dimension. E.g. {"x": 0.95, "y": 2.15} upper (dict): Dict of str position_name -> float upper_bound for each scannable dimension. E.g. {"x": 1.05, "y": 2.25} indexes (list): List of int indexes for each dataset dimension, fastest changing last. E.g. [15] """ def __init__(self): self.positions = {} self.lower = {} self.upper = {} self.indexes = []
Update Point to use normal dictionaries for its coordinates
Update Point to use normal dictionaries for its coordinates
Python
apache-2.0
dls-controls/scanpointgenerator
eb1d581a94f87feb2bc09dbf45b13de282a205e8
pyqode/json/modes/autocomplete.py
pyqode/json/modes/autocomplete.py
from pyqode.core import modes from pyqode.core.api import TextHelper class AutoCompleteMode(modes.AutoCompleteMode): def __init__(self): super(AutoCompleteMode, self).__init__() self.QUOTES_FORMATS.pop("'") self.SELECTED_QUOTES_FORMATS.pop("'") self.MAPPING.pop("'") def _on_key_pressed(self, event): helper = TextHelper(self.editor) indent = helper.line_indent() * ' ' if self.editor.textCursor().positionInBlock() == len(indent): self.QUOTES_FORMATS['"'] = '%s:' else: self.QUOTES_FORMATS['"'] = '%s' self.QUOTES_FORMATS['{'] = '\n' + indent + '%s' self.QUOTES_FORMATS['['] = '\n' + indent + '%s' super(AutoCompleteMode, self)._on_key_pressed(event)
from pyqode.core import modes from pyqode.core.api import TextHelper class AutoCompleteMode(modes.AutoCompleteMode): def __init__(self): super(AutoCompleteMode, self).__init__() try: self.QUOTES_FORMATS.pop("'") self.SELECTED_QUOTES_FORMATS.pop("'") self.MAPPING.pop("'") except KeyError: pass def _on_key_pressed(self, event): helper = TextHelper(self.editor) indent = helper.line_indent() * ' ' if self.editor.textCursor().positionInBlock() == len(indent): self.QUOTES_FORMATS['"'] = '%s:' else: self.QUOTES_FORMATS['"'] = '%s' self.QUOTES_FORMATS['{'] = '\n' + indent + '%s' self.QUOTES_FORMATS['['] = '\n' + indent + '%s' super(AutoCompleteMode, self)._on_key_pressed(event)
Fix issue with auto complete when more than 1 editor has been created
Fix issue with auto complete when more than 1 editor has been created
Python
mit
pyQode/pyqode.json,pyQode/pyqode.json
a60fa6989abd1080cafc860121885ec210d16771
script/update-frameworks.py
script/update-frameworks.py
#!/usr/bin/env python import sys import os from lib.util import safe_mkdir, extract_zip, tempdir, download SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) FRAMEWORKS_URL = 'https://github.com/atom/atom-shell/releases/download/v0.11.10' def main(): os.chdir(SOURCE_ROOT) safe_mkdir('frameworks') download_and_unzip('Mantle') download_and_unzip('ReactiveCocoa') download_and_unzip('Squirrel') def download_and_unzip(framework): zip_path = download_framework(framework) if zip_path: extract_zip(zip_path, 'frameworks') def download_framework(framework): framework_path = os.path.join('frameworks', framework) + '.framework' if os.path.exists(framework_path): return filename = framework + '.framework.zip' url = FRAMEWORKS_URL + '/' + filename download_dir = tempdir(prefix='atom-shell-') path = os.path.join(download_dir, filename) download('Download ' + framework, url, path) return path if __name__ == '__main__': sys.exit(main())
#!/usr/bin/env python import sys import os from lib.util import safe_mkdir, extract_zip, tempdir, download SOURCE_ROOT = os.path.abspath(os.path.dirname(os.path.dirname(__file__))) FRAMEWORKS_URL = 'https://github.com/atom/atom-shell-frameworks/releases/download/v0.0.1' def main(): os.chdir(SOURCE_ROOT) safe_mkdir('frameworks') download_and_unzip('Mantle') download_and_unzip('ReactiveCocoa') download_and_unzip('Squirrel') def download_and_unzip(framework): zip_path = download_framework(framework) if zip_path: extract_zip(zip_path, 'frameworks') def download_framework(framework): framework_path = os.path.join('frameworks', framework) + '.framework' if os.path.exists(framework_path): return filename = framework + '.framework.zip' url = FRAMEWORKS_URL + '/' + filename download_dir = tempdir(prefix='atom-shell-') path = os.path.join(download_dir, filename) download('Download ' + framework, url, path) return path if __name__ == '__main__': sys.exit(main())
Use atom/atom-shell-frameworks until atom/atom-shell is public
Use atom/atom-shell-frameworks until atom/atom-shell is public
Python
mit
Rokt33r/electron,shiftkey/electron,Jacobichou/electron,shaundunne/electron,systembugtj/electron,dkfiresky/electron,subblue/electron,wan-qy/electron,brave/muon,preco21/electron,farmisen/electron,icattlecoder/electron,sshiting/electron,dkfiresky/electron,kostia/electron,MaxWhere/electron,chrisswk/electron,electron/electron,mrwizard82d1/electron,yan-foto/electron,posix4e/electron,Rokt33r/electron,jonatasfreitasv/electron,chriskdon/electron,hokein/atom-shell,thomsonreuters/electron,the-ress/electron,LadyNaggaga/electron,kenmozi/electron,brenca/electron,kenmozi/electron,aichingm/electron,ankitaggarwal011/electron,subblue/electron,natgolov/electron,edulan/electron,arturts/electron,jaanus/electron,tylergibson/electron,minggo/electron,robinvandernoord/electron,ianscrivener/electron,zhakui/electron,lrlna/electron,RIAEvangelist/electron,nekuz0r/electron,MaxGraey/electron,aaron-goshine/electron,jonatasfreitasv/electron,roadev/electron,d-salas/electron,jaanus/electron,bpasero/electron,deepak1556/atom-shell,kazupon/electron,arusakov/electron,JussMee15/electron,gbn972/electron,thingsinjars/electron,thompsonemerson/electron,ankitaggarwal011/electron,electron/electron,matiasinsaurralde/electron,fffej/electron,Floato/electron,matiasinsaurralde/electron,wolfflow/electron,benweissmann/electron,yalexx/electron,faizalpribadi/electron,preco21/electron,felixrieseberg/electron,bruce/electron,kazupon/electron,stevemao/electron,jiaz/electron,stevemao/electron,aliib/electron,trigrass2/electron,mrwizard82d1/electron,biblerule/UMCTelnetHub,wolfflow/electron,lrlna/electron,trankmichael/electron,coderhaoxin/electron,shockone/electron,deed02392/electron,wolfflow/electron,beni55/electron,Jonekee/electron,edulan/electron,destan/electron,coderhaoxin/electron,astoilkov/electron,astoilkov/electron,Jacobichou/electron,gamedevsam/electron,pirafrank/electron,digideskio/electron,webmechanicx/electron,etiktin/electron,fffej/electron,bwiggs/electron,gbn972/electron,maxogden/atom-shell,howmuchcomputer/electron,leolujuyi/electron,JussMee15/electron,thingsinjars/electron,meowlab/electron,sircharleswatson/electron,gabrielPeart/electron,noikiy/electron,simongregory/electron,lzpfmh/electron,rajatsingla28/electron,Evercoder/electron,micalan/electron,chrisswk/electron,baiwyc119/electron,hokein/atom-shell,Floato/electron,voidbridge/electron,ianscrivener/electron,dkfiresky/electron,seanchas116/electron,michaelchiche/electron,smczk/electron,bitemyapp/electron,brenca/electron,twolfson/electron,John-Lin/electron,pandoraui/electron,bbondy/electron,RIAEvangelist/electron,saronwei/electron,meowlab/electron,webmechanicx/electron,gamedevsam/electron,xiruibing/electron,vHanda/electron,shiftkey/electron,meowlab/electron,yan-foto/electron,seanchas116/electron,arusakov/electron,xfstudio/electron,systembugtj/electron,pirafrank/electron,rreimann/electron,shiftkey/electron,gabrielPeart/electron,bruce/electron,coderhaoxin/electron,stevemao/electron,mrwizard82d1/electron,fritx/electron,arusakov/electron,brave/muon,bwiggs/electron,synaptek/electron,bright-sparks/electron,gbn972/electron,gerhardberger/electron,medixdev/electron,Jacobichou/electron,felixrieseberg/electron,fabien-d/electron,electron/electron,mrwizard82d1/electron,Zagorakiss/electron,kenmozi/electron,JesselJohn/electron,ervinb/electron,joneit/electron,fireball-x/atom-shell,Jonekee/electron,hokein/atom-shell,mubassirhayat/electron,astoilkov/electron,Ivshti/electron,cos2004/electron,wolfflow/electron,fireball-x/atom-shell,nicholasess/electron,kazupon/electron,shaundunne/electron,fffej/electron,preco21/electron,sshiting/electron,kcrt/electron,lrlna/electron,nagyistoce/electron-atom-shell,Zagorakiss/electron,Evercoder/electron,thomsonreuters/electron,bobwol/electron,tincan24/electron,IonicaBizauKitchen/electron,ianscrivener/electron,faizalpribadi/electron,brave/muon,twolfson/electron,chrisswk/electron,subblue/electron,bwiggs/electron,rhencke/electron,zhakui/electron,deepak1556/atom-shell,stevekinney/electron,sircharleswatson/electron,joneit/electron,bruce/electron,synaptek/electron,MaxGraey/electron,anko/electron,leethomas/electron,aecca/electron,mattdesl/electron,bright-sparks/electron,bbondy/electron,leftstick/electron,vHanda/electron,mjaniszew/electron,medixdev/electron,cqqccqc/electron,aliib/electron,jhen0409/electron,cqqccqc/electron,kenmozi/electron,greyhwndz/electron,MaxWhere/electron,pombredanne/electron,shiftkey/electron,cos2004/electron,twolfson/electron,leolujuyi/electron,thingsinjars/electron,voidbridge/electron,christian-bromann/electron,thomsonreuters/electron,bright-sparks/electron,leethomas/electron,Zagorakiss/electron,LadyNaggaga/electron,Andrey-Pavlov/electron,jacksondc/electron,darwin/electron,shockone/electron,renaesop/electron,rprichard/electron,rreimann/electron,rsvip/electron,jlhbaseball15/electron,yalexx/electron,jtburke/electron,rsvip/electron,tylergibson/electron,ianscrivener/electron,beni55/electron,fireball-x/atom-shell,DivyaKMenon/electron,synaptek/electron,kikong/electron,rajatsingla28/electron,mirrh/electron,kostia/electron,simongregory/electron,thingsinjars/electron,gerhardberger/electron,gstack/infinium-shell,RobertJGabriel/electron,jjz/electron,sky7sea/electron,biblerule/UMCTelnetHub,vHanda/electron,rsvip/electron,mattotodd/electron,trigrass2/electron,SufianHassan/electron,biblerule/UMCTelnetHub,adamjgray/electron,benweissmann/electron,jannishuebl/electron,robinvandernoord/electron,jsutcodes/electron,tonyganch/electron,DivyaKMenon/electron,JesselJohn/electron,thomsonreuters/electron,bright-sparks/electron,wan-qy/electron,beni55/electron,digideskio/electron,renaesop/electron,jacksondc/electron,saronwei/electron,adcentury/electron,takashi/electron,Rokt33r/electron,Jacobichou/electron,jsutcodes/electron,nagyistoce/electron-atom-shell,egoist/electron,rreimann/electron,faizalpribadi/electron,carsonmcdonald/electron,nicobot/electron,eric-seekas/electron,miniak/electron,cqqccqc/electron,iftekeriba/electron,kikong/electron,ankitaggarwal011/electron,stevemao/electron,jacksondc/electron,gabrielPeart/electron,twolfson/electron,icattlecoder/electron,brenca/electron,deed02392/electron,eriser/electron,meowlab/electron,jtburke/electron,mirrh/electron,cqqccqc/electron,GoooIce/electron,nekuz0r/electron,mattotodd/electron,tomashanacek/electron,dongjoon-hyun/electron,michaelchiche/electron,BionicClick/electron,Faiz7412/electron,adamjgray/electron,deepak1556/atom-shell,medixdev/electron,bpasero/electron,rsvip/electron,leolujuyi/electron,jtburke/electron,kostia/electron,gstack/infinium-shell,shockone/electron,adcentury/electron,Andrey-Pavlov/electron,vaginessa/electron,evgenyzinoviev/electron,takashi/electron,cos2004/electron,pombredanne/electron,jsutcodes/electron,adcentury/electron,eric-seekas/electron,howmuchcomputer/electron,sky7sea/electron,fritx/electron,rprichard/electron,roadev/electron,systembugtj/electron,leethomas/electron,shennushi/electron,adamjgray/electron,fabien-d/electron,BionicClick/electron,adcentury/electron,arturts/electron,Gerhut/electron,stevekinney/electron,bbondy/electron,mrwizard82d1/electron,nagyistoce/electron-atom-shell,setzer777/electron,jlord/electron,brave/muon,Ivshti/electron,farmisen/electron,baiwyc119/electron,ervinb/electron,subblue/electron,thomsonreuters/electron,thompsonemerson/electron,oiledCode/electron,chriskdon/electron,mattdesl/electron,simonfork/electron,kikong/electron,aliib/electron,meowlab/electron,minggo/electron,egoist/electron,leftstick/electron,rsvip/electron,DivyaKMenon/electron,mjaniszew/electron,Andrey-Pavlov/electron,bobwol/electron,fomojola/electron,tomashanacek/electron,lrlna/electron,adamjgray/electron,soulteary/electron,etiktin/electron,benweissmann/electron,John-Lin/electron,zhakui/electron,sircharleswatson/electron,vaginessa/electron,RIAEvangelist/electron,ianscrivener/electron,vaginessa/electron,posix4e/electron,tinydew4/electron,nicholasess/electron,setzer777/electron,gerhardberger/electron,wolfflow/electron,vaginessa/electron,sircharleswatson/electron,gabrielPeart/electron,kazupon/electron,gabrielPeart/electron,voidbridge/electron,simonfork/electron,jtburke/electron,edulan/electron,eriser/electron,shennushi/electron,JussMee15/electron,JussMee15/electron,abhishekgahlot/electron,jonatasfreitasv/electron,mubassirhayat/electron,deed02392/electron,gerhardberger/electron,IonicaBizauKitchen/electron,carsonmcdonald/electron,shockone/electron,etiktin/electron,astoilkov/electron,pirafrank/electron,gabriel/electron,JesselJohn/electron,bright-sparks/electron,SufianHassan/electron,vipulroxx/electron,aaron-goshine/electron,evgenyzinoviev/electron,trigrass2/electron,kenmozi/electron,davazp/electron,posix4e/electron,robinvandernoord/electron,GoooIce/electron,thompsonemerson/electron,mjaniszew/electron,kostia/electron,matiasinsaurralde/electron,jsutcodes/electron,etiktin/electron,natgolov/electron,nicobot/electron,aichingm/electron,jjz/electron,meowlab/electron,nicobot/electron,IonicaBizauKitchen/electron,dongjoon-hyun/electron,Ivshti/electron,John-Lin/electron,oiledCode/electron,joneit/electron,webmechanicx/electron,fabien-d/electron,jcblw/electron,trankmichael/electron,jonatasfreitasv/electron,sky7sea/electron,mhkeller/electron,benweissmann/electron,trankmichael/electron,jsutcodes/electron,xiruibing/electron,synaptek/electron,takashi/electron,kostia/electron,lrlna/electron,the-ress/electron,jlord/electron,evgenyzinoviev/electron,saronwei/electron,jonatasfreitasv/electron,simongregory/electron,John-Lin/electron,aecca/electron,arturts/electron,michaelchiche/electron,roadev/electron,the-ress/electron,greyhwndz/electron,tomashanacek/electron,neutrous/electron,lzpfmh/electron,JussMee15/electron,thomsonreuters/electron,jsutcodes/electron,jhen0409/electron,leftstick/electron,bitemyapp/electron,smczk/electron,icattlecoder/electron,kazupon/electron,fomojola/electron,deepak1556/atom-shell,aliib/electron,systembugtj/electron,arusakov/electron,timruffles/electron,Gerhut/electron,trigrass2/electron,gamedevsam/electron,Andrey-Pavlov/electron,electron/electron,oiledCode/electron,carsonmcdonald/electron,tylergibson/electron,leethomas/electron,howmuchcomputer/electron,farmisen/electron,ankitaggarwal011/electron,icattlecoder/electron,jlord/electron,thingsinjars/electron,maxogden/atom-shell,baiwyc119/electron,darwin/electron,xfstudio/electron,Jacobichou/electron,shennushi/electron,mubassirhayat/electron,dahal/electron,bright-sparks/electron,sircharleswatson/electron,d-salas/electron,medixdev/electron,lzpfmh/electron,sircharleswatson/electron,cos2004/electron,shennushi/electron,maxogden/atom-shell,rhencke/electron,smczk/electron,medixdev/electron,adcentury/electron,bbondy/electron,tincan24/electron,d-salas/electron,subblue/electron,eric-seekas/electron,Zagorakiss/electron,aichingm/electron,arusakov/electron,Jonekee/electron,darwin/electron,robinvandernoord/electron,jaanus/electron,chriskdon/electron,Jonekee/electron,systembugtj/electron,tomashanacek/electron,noikiy/electron,noikiy/electron,destan/electron,Ivshti/electron,bpasero/electron,etiktin/electron,destan/electron,chriskdon/electron,DivyaKMenon/electron,aaron-goshine/electron,gbn972/electron,fritx/electron,Zagorakiss/electron,leftstick/electron,pombredanne/electron,mhkeller/electron,shaundunne/electron,micalan/electron,sky7sea/electron,gamedevsam/electron,zhakui/electron,xfstudio/electron,chriskdon/electron,dahal/electron,gstack/infinium-shell,RIAEvangelist/electron,vipulroxx/electron,aaron-goshine/electron,icattlecoder/electron,dongjoon-hyun/electron,jcblw/electron,gbn972/electron,dongjoon-hyun/electron,vHanda/electron,neutrous/electron,gerhardberger/electron,gabrielPeart/electron,neutrous/electron,rajatsingla28/electron,seanchas116/electron,RobertJGabriel/electron,anko/electron,trigrass2/electron,shaundunne/electron,medixdev/electron,Neron-X5/electron,thompsonemerson/electron,anko/electron,christian-bromann/electron,christian-bromann/electron,jannishuebl/electron,soulteary/electron,jiaz/electron,the-ress/electron,voidbridge/electron,etiktin/electron,joaomoreno/atom-shell,jcblw/electron,bitemyapp/electron,nekuz0r/electron,roadev/electron,arturts/electron,rajatsingla28/electron,tonyganch/electron,stevekinney/electron,wan-qy/electron,mirrh/electron,neutrous/electron,simonfork/electron,matiasinsaurralde/electron,takashi/electron,brave/electron,preco21/electron,jlhbaseball15/electron,abhishekgahlot/electron,nicobot/electron,fomojola/electron,brenca/electron,egoist/electron,astoilkov/electron,kokdemo/electron,miniak/electron,rhencke/electron,ervinb/electron,sshiting/electron,bpasero/electron,evgenyzinoviev/electron,howmuchcomputer/electron,dahal/electron,jannishuebl/electron,eriser/electron,tonyganch/electron,anko/electron,tinydew4/electron,vaginessa/electron,tomashanacek/electron,tylergibson/electron,SufianHassan/electron,oiledCode/electron,ervinb/electron,brave/electron,matiasinsaurralde/electron,SufianHassan/electron,darwin/electron,fomojola/electron,jlord/electron,stevekinney/electron,posix4e/electron,kostia/electron,brave/electron,fabien-d/electron,shiftkey/electron,MaxWhere/electron,SufianHassan/electron,michaelchiche/electron,egoist/electron,pandoraui/electron,lzpfmh/electron,kokdemo/electron,synaptek/electron,rhencke/electron,SufianHassan/electron,digideskio/electron,adamjgray/electron,Neron-X5/electron,jaanus/electron,leolujuyi/electron,pombredanne/electron,natgolov/electron,carsonmcdonald/electron,trankmichael/electron,abhishekgahlot/electron,LadyNaggaga/electron,jjz/electron,eric-seekas/electron,jiaz/electron,astoilkov/electron,the-ress/electron,rreimann/electron,nicobot/electron,RobertJGabriel/electron,brave/electron,minggo/electron,jannishuebl/electron,minggo/electron,natgolov/electron,abhishekgahlot/electron,farmisen/electron,Gerhut/electron,vaginessa/electron,DivyaKMenon/electron,IonicaBizauKitchen/electron,ankitaggarwal011/electron,edulan/electron,DivyaKMenon/electron,miniak/electron,jcblw/electron,posix4e/electron,farmisen/electron,dahal/electron,renaesop/electron,tonyganch/electron,d-salas/electron,kcrt/electron,cos2004/electron,jtburke/electron,iftekeriba/electron,coderhaoxin/electron,bwiggs/electron,anko/electron,wan-qy/electron,cos2004/electron,bbondy/electron,bwiggs/electron,michaelchiche/electron,mattotodd/electron,kazupon/electron,bobwol/electron,benweissmann/electron,mrwizard82d1/electron,oiledCode/electron,setzer777/electron,yalexx/electron,GoooIce/electron,pandoraui/electron,jlhbaseball15/electron,aichingm/electron,mjaniszew/electron,deed02392/electron,electron/electron,saronwei/electron,bobwol/electron,yan-foto/electron,christian-bromann/electron,fireball-x/atom-shell,twolfson/electron,abhishekgahlot/electron,soulteary/electron,pirafrank/electron,MaxGraey/electron,d-salas/electron,electron/electron,yan-foto/electron,yalexx/electron,stevekinney/electron,ankitaggarwal011/electron,yan-foto/electron,tincan24/electron,miniak/electron,destan/electron,arusakov/electron,davazp/electron,deepak1556/atom-shell,edulan/electron,shockone/electron,gerhardberger/electron,bruce/electron,yan-foto/electron,soulteary/electron,renaesop/electron,kcrt/electron,beni55/electron,digideskio/electron,fffej/electron,kokdemo/electron,bitemyapp/electron,gabriel/electron,jaanus/electron,Gerhut/electron,leolujuyi/electron,micalan/electron,bruce/electron,electron/electron,nagyistoce/electron-atom-shell,gabriel/electron,nekuz0r/electron,neutrous/electron,jcblw/electron,thompsonemerson/electron,jhen0409/electron,John-Lin/electron,kikong/electron,iftekeriba/electron,leolujuyi/electron,mattdesl/electron,saronwei/electron,jjz/electron,Rokt33r/electron,timruffles/electron,LadyNaggaga/electron,tinydew4/electron,jlhbaseball15/electron,roadev/electron,synaptek/electron,pombredanne/electron,soulteary/electron,robinvandernoord/electron,takashi/electron,dkfiresky/electron,ianscrivener/electron,kokdemo/electron,fffej/electron,farmisen/electron,JesselJohn/electron,gstack/infinium-shell,tincan24/electron,kokdemo/electron,aichingm/electron,fritx/electron,aliib/electron,RobertJGabriel/electron,eriser/electron,yalexx/electron,Floato/electron,Rokt33r/electron,joneit/electron,christian-bromann/electron,gabriel/electron,nekuz0r/electron,shennushi/electron,wolfflow/electron,tinydew4/electron,webmechanicx/electron,pandoraui/electron,mattotodd/electron,iftekeriba/electron,mirrh/electron,Floato/electron,xiruibing/electron,destan/electron,evgenyzinoviev/electron,felixrieseberg/electron,gamedevsam/electron,IonicaBizauKitchen/electron,zhakui/electron,trankmichael/electron,tylergibson/electron,timruffles/electron,nicholasess/electron,felixrieseberg/electron,mhkeller/electron,bbondy/electron,dahal/electron,arturts/electron,RobertJGabriel/electron,howmuchcomputer/electron,vHanda/electron,rajatsingla28/electron,evgenyzinoviev/electron,seanchas116/electron,tonyganch/electron,nicholasess/electron,jcblw/electron,Evercoder/electron,Gerhut/electron,mattotodd/electron,simonfork/electron,mhkeller/electron,bpasero/electron,Rokt33r/electron,baiwyc119/electron,kcrt/electron,jhen0409/electron,Neron-X5/electron,simongregory/electron,renaesop/electron,RIAEvangelist/electron,sshiting/electron,jiaz/electron,xfstudio/electron,neutrous/electron,aecca/electron,leethomas/electron,miniak/electron,faizalpribadi/electron,MaxGraey/electron,noikiy/electron,rhencke/electron,GoooIce/electron,chrisswk/electron,beni55/electron,jjz/electron,nekuz0r/electron,hokein/atom-shell,BionicClick/electron,lzpfmh/electron,brave/electron,gabriel/electron,Zagorakiss/electron,kcrt/electron,IonicaBizauKitchen/electron,preco21/electron,trigrass2/electron,greyhwndz/electron,Gerhut/electron,joneit/electron,Jonekee/electron,shiftkey/electron,tincan24/electron,aecca/electron,pandoraui/electron,nicholasess/electron,smczk/electron,darwin/electron,nicholasess/electron,faizalpribadi/electron,arturts/electron,stevekinney/electron,christian-bromann/electron,timruffles/electron,timruffles/electron,jlhbaseball15/electron,biblerule/UMCTelnetHub,leftstick/electron,simongregory/electron,voidbridge/electron,icattlecoder/electron,Floato/electron,Ivshti/electron,MaxWhere/electron,davazp/electron,mirrh/electron,lzpfmh/electron,vipulroxx/electron,faizalpribadi/electron,minggo/electron,lrlna/electron,simonfork/electron,Andrey-Pavlov/electron,fireball-x/atom-shell,digideskio/electron,chriskdon/electron,renaesop/electron,aichingm/electron,BionicClick/electron,adamjgray/electron,eric-seekas/electron,edulan/electron,deed02392/electron,micalan/electron,vHanda/electron,subblue/electron,greyhwndz/electron,jannishuebl/electron,brave/muon,brenca/electron,gbn972/electron,thingsinjars/electron,zhakui/electron,aecca/electron,mjaniszew/electron,leftstick/electron,simonfork/electron,kcrt/electron,Neron-X5/electron,pirafrank/electron,roadev/electron,jaanus/electron,dongjoon-hyun/electron,rhencke/electron,rprichard/electron,gamedevsam/electron,micalan/electron,kokdemo/electron,maxogden/atom-shell,twolfson/electron,vipulroxx/electron,thompsonemerson/electron,shockone/electron,bwiggs/electron,shennushi/electron,baiwyc119/electron,sky7sea/electron,kenmozi/electron,joaomoreno/atom-shell,maxogden/atom-shell,soulteary/electron,xiruibing/electron,yalexx/electron,jacksondc/electron,fritx/electron,bpasero/electron,davazp/electron,xiruibing/electron,adcentury/electron,rreimann/electron,mattotodd/electron,Jacobichou/electron,brave/muon,kikong/electron,micalan/electron,jhen0409/electron,webmechanicx/electron,seanchas116/electron,aecca/electron,cqqccqc/electron,hokein/atom-shell,RobertJGabriel/electron,anko/electron,greyhwndz/electron,miniak/electron,felixrieseberg/electron,jiaz/electron,aliib/electron,webmechanicx/electron,fabien-d/electron,coderhaoxin/electron,preco21/electron,aaron-goshine/electron,sky7sea/electron,simongregory/electron,davazp/electron,Andrey-Pavlov/electron,dkfiresky/electron,JussMee15/electron,setzer777/electron,setzer777/electron,oiledCode/electron,tinydew4/electron,aaron-goshine/electron,brave/electron,MaxWhere/electron,Faiz7412/electron,greyhwndz/electron,smczk/electron,the-ress/electron,carsonmcdonald/electron,digideskio/electron,stevemao/electron,bobwol/electron,BionicClick/electron,xiruibing/electron,GoooIce/electron,rajatsingla28/electron,Faiz7412/electron,xfstudio/electron,posix4e/electron,robinvandernoord/electron,LadyNaggaga/electron,Evercoder/electron,mubassirhayat/electron,joaomoreno/atom-shell,mirrh/electron,matiasinsaurralde/electron,eric-seekas/electron,rreimann/electron,cqqccqc/electron,jhen0409/electron,beni55/electron,wan-qy/electron,benweissmann/electron,pirafrank/electron,MaxWhere/electron,howmuchcomputer/electron,tonyganch/electron,mattdesl/electron,Neron-X5/electron,nicobot/electron,vipulroxx/electron,dahal/electron,sshiting/electron,natgolov/electron,Faiz7412/electron,pandoraui/electron,setzer777/electron,fomojola/electron,Faiz7412/electron,felixrieseberg/electron,bitemyapp/electron,brenca/electron,shaundunne/electron,sshiting/electron,davazp/electron,jannishuebl/electron,jlhbaseball15/electron,seanchas116/electron,mattdesl/electron,jiaz/electron,Evercoder/electron,jacksondc/electron,shaundunne/electron,BionicClick/electron,jtburke/electron,MaxGraey/electron,voidbridge/electron,abhishekgahlot/electron,ervinb/electron,baiwyc119/electron,carsonmcdonald/electron,jlord/electron,bobwol/electron,LadyNaggaga/electron,tincan24/electron,noikiy/electron,the-ress/electron,Floato/electron,saronwei/electron,takashi/electron,tylergibson/electron,minggo/electron,egoist/electron,deed02392/electron,systembugtj/electron,destan/electron,smczk/electron,fffej/electron,biblerule/UMCTelnetHub,jacksondc/electron,Jonekee/electron,ervinb/electron,joaomoreno/atom-shell,gabriel/electron,mhkeller/electron,eriser/electron,mhkeller/electron,leethomas/electron,stevemao/electron,eriser/electron,bitemyapp/electron,nagyistoce/electron-atom-shell,michaelchiche/electron,JesselJohn/electron,GoooIce/electron,John-Lin/electron,dongjoon-hyun/electron,tinydew4/electron,noikiy/electron,Evercoder/electron,fritx/electron,natgolov/electron,biblerule/UMCTelnetHub,coderhaoxin/electron,jjz/electron,joneit/electron,dkfiresky/electron,vipulroxx/electron,tomashanacek/electron,mubassirhayat/electron,chrisswk/electron,wan-qy/electron,jonatasfreitasv/electron,xfstudio/electron,gstack/infinium-shell,fomojola/electron,JesselJohn/electron,mjaniszew/electron,egoist/electron,mattdesl/electron,joaomoreno/atom-shell,joaomoreno/atom-shell,trankmichael/electron,bruce/electron,d-salas/electron,iftekeriba/electron,bpasero/electron,RIAEvangelist/electron,pombredanne/electron,rprichard/electron,Neron-X5/electron,gerhardberger/electron,iftekeriba/electron
9445c23e70cabe519d51282bf4849a8d08e21039
robotpy_ext/misc/precise_delay.py
robotpy_ext/misc/precise_delay.py
import wpilib class PreciseDelay: ''' Used to synchronize a timing loop. Usage:: delay = PreciseDelay(time_to_delay) while something: # do things here delay.wait() ''' def __init__(self, delay_period): ''' :param delay_period: The amount of time to do a delay :type delay_period: float ''' self.delay = wpilib.Timer.delay self.timer = wpilib.Timer() self.delay_period = delay_period self.timer.start() def wait(self): '''Waits until the delay period has passed''' # we must *always* yield here, so other things can run self.delay(0.001) while not self.timer.hasPeriodPassed(self.delay_period): self.delay(0.001)
import hal import time import wpilib class PreciseDelay: ''' Used to synchronize a timing loop. Will delay precisely so that the next invocation of your loop happens at the same period, as long as your code does not run longer than the length of the delay. Our experience has shown that 25ms is a good loop period. Usage:: delay = PreciseDelay(time_to_delay) while something: # do things here delay.wait() ''' def __init__(self, delay_period): ''' :param delay_period: The amount of time (in seconds) to do a delay :type delay_period: float ''' # The WPILib sleep/etc functions are slightly less stable as # they have more overhead, so only use them in simulation mode if hal.HALIsSimulation: self.delay = wpilib.Timer.delay self.get_now = wpilib.Timer.getFPGATimestamp else: self.delay = time.sleep self.get_now = time.time self.delay_period = float(delay_period) if self.delay_period < 0.001: raise ValueError("You probably don't want to delay less than 1ms!") self.next_delay = self.get_now() + self.delay_period def wait(self): '''Waits until the delay period has passed''' # optimization -- avoid local lookups delay = self.delay get_now = self.get_now next_delay = self.next_delay while True: # we must *always* yield here, so other things can run delay(0.0002) if next_delay < get_now(): break self.next_delay += self.delay_period
Fix PreciseDelay to work properly
Fix PreciseDelay to work properly
Python
bsd-3-clause
robotpy/robotpy-wpilib-utilities,Twinters007/robotpy-wpilib-utilities,robotpy/robotpy-wpilib-utilities,Twinters007/robotpy-wpilib-utilities
e4fcebfe4e87b57ae8505437f54c69f3afd59c04
python/tests.py
python/tests.py
#!/usr/bin/env python """ Created on Thu 6 March 2014 Contains testing routines for `SolarCoreModel.py`. @author Kristoffer Braekken """ import SolarCoreModel from numpy import log10 def opacity_test(tol=1.e-10): """ Function for testing that the opacity is fetched correctly. """ # Test values T = 10**(5.) # Feth 5.00 row rho = 1.e-6 # Fetch -5.0 column ans = log10(SolarCoreModel.kappa(T, rho)) if abs(ans - (-0.068)) < tol: print 'Sucess.' else: print 'Fail.\n10**kappa =', ans, 'and not -0.068.' if __name__ == '__main__': opacity_test()
#!/usr/bin/env python """ Created on Thu 6 March 2014 Contains testing routines for `SolarCoreModel.py`. @author Kristoffer Braekken """ import SolarCoreModel from numpy import log10 def opacity_test(tol=1.e-10): """ Function for testing that the opacity is fetched correctly. """ # Test values T = 10**(5.) # Feth 5.00 row rho = 1.e-6 # Fetch -5.0 column rho /= 1.e3; rho *= 1./1e6 # Convert to SI units [kg m^-3] ans = log10(SolarCoreModel.kappa(T, rho)) if abs(ans - (-0.068)) < tol: print 'Sucess.' else: print 'Fail.\n10**kappa =', ans, 'and not -0.068.' if __name__ == '__main__': opacity_test()
Fix test to take care of units.
TODO: Fix test to take care of units.
Python
mit
PaulMag/AST3310-Prj01,PaulMag/AST3310-Prj01
09a6e2528f062581c90ed3f3225f19b36f0ac0f9
eve_api/forms.py
eve_api/forms.py
import re from django import forms from eve_api.models import EVEAccount, EVEPlayerCharacter, EVEPlayerCorporation class EveAPIForm(forms.Form): """ EVE API input form """ user_id = forms.IntegerField(label=u'User ID') api_key = forms.CharField(label=u'API Key', max_length=64) description = forms.CharField(max_length=100, required=False) def clean_api_key(self): if not len(self.cleaned_data['api_key']) == 64: raise forms.ValidationError("Provided API Key is not 64 characters long.") if re.search(r'[^\.a-zA-Z0-9]', self.cleaned_data['api_key']): raise forms.ValidationError("Provided API Key has invalid characters.") def clean_user_id(self): if not 'user_id' in self.cleaned_data or self.cleaned_data['user_id'] == '': raise forms.ValidationError("Please provide a valid User ID") try: eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['user_id']) except EVEAccount.DoesNotExist: return self.cleaned_data else: raise forms.ValidationError("This API User ID is already registered")
import re from django import forms from eve_api.models import EVEAccount, EVEPlayerCharacter, EVEPlayerCorporation class EveAPIForm(forms.Form): """ EVE API input form """ user_id = forms.IntegerField(label=u'User ID') api_key = forms.CharField(label=u'API Key', max_length=64) description = forms.CharField(max_length=100, required=False) def clean_api_key(self): if not len(self.cleaned_data['api_key']) == 64: raise forms.ValidationError("Provided API Key is not 64 characters long.") if re.search(r'[^\.a-zA-Z0-9]', self.cleaned_data['api_key']): raise forms.ValidationError("Provided API Key has invalid characters.") return self.cleaned_data['api_key'] def clean_user_id(self): if not 'user_id' in self.cleaned_data or self.cleaned_data['user_id'] == '': raise forms.ValidationError("Please provide a valid User ID") try: eaccount = EVEAccount.objects.get(api_user_id=self.cleaned_data['user_id']) except EVEAccount.DoesNotExist: pass else: raise forms.ValidationError("This API User ID is already registered") return self.cleaned_data['user_id']
Fix the validation data on the EVEAPIForm
Fix the validation data on the EVEAPIForm
Python
bsd-3-clause
nikdoof/test-auth
216f128bb8baf65a06c1f35356ab0f7fe50db967
telemetry/telemetry/core/backends/chrome/inspector_memory_unittest.py
telemetry/telemetry/core/backends/chrome/inspector_memory_unittest.py
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from telemetry import benchmark from telemetry.unittest import tab_test_case class InspectorMemoryTest(tab_test_case.TabTestCase): @benchmark.Enabled('has tabs') def testGetDOMStats(self): # Due to an issue with CrOS, we create a new tab here rather than # using the existing tab to get a consistent starting page on all platforms. self._tab = self._browser.tabs.New() self.Navigate('dom_counter_sample.html') counts = self._tab.dom_stats self.assertEqual(counts['document_count'], 1) self.assertEqual(counts['node_count'], 14) self.assertEqual(counts['event_listener_count'], 2)
# Copyright 2013 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from telemetry import benchmark from telemetry.unittest import tab_test_case class InspectorMemoryTest(tab_test_case.TabTestCase): @benchmark.Enabled('has tabs') def testGetDOMStats(self): # Due to an issue with CrOS, we create a new tab here rather than # using the existing tab to get a consistent starting page on all platforms. self._tab = self._browser.tabs.New() self.Navigate('dom_counter_sample.html') # Document_count > 1 indicates that WebCore::Document loaded in Chrome # is leaking! The baseline should exactly match the numbers on: # unittest_data/dom_counter_sample.html # Please contact kouhei@, hajimehoshi@ when rebaselining. counts = self._tab.dom_stats self.assertEqual(counts['document_count'], 1, 'Document leak is detected! '+ 'The previous document is likely retained unexpectedly.') self.assertEqual(counts['node_count'], 14, 'Node leak is detected!') self.assertEqual(counts['event_listener_count'], 2, 'EventListener leak is detected!')
Add warnings to inspector DOM count unittest baselines.
Add warnings to inspector DOM count unittest baselines. The unit test failure indicates a serious Document leak, where all WebCore::Document loaded in Chrome is leaking. This CL adds warning comments to the baseline to avoid regressions. BUG=392121 NOTRY=true Review URL: https://codereview.chromium.org/393123003 git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@284653 0039d316-1c4b-4281-b951-d872f2087c98
Python
bsd-3-clause
SummerLW/Perf-Insight-Report,benschmaus/catapult,catapult-project/catapult-csm,catapult-project/catapult-csm,SummerLW/Perf-Insight-Report,catapult-project/catapult,catapult-project/catapult-csm,benschmaus/catapult,catapult-project/catapult-csm,catapult-project/catapult,sahiljain/catapult,SummerLW/Perf-Insight-Report,benschmaus/catapult,SummerLW/Perf-Insight-Report,sahiljain/catapult,catapult-project/catapult-csm,SummerLW/Perf-Insight-Report,sahiljain/catapult,benschmaus/catapult,catapult-project/catapult-csm,sahiljain/catapult,catapult-project/catapult,catapult-project/catapult,catapult-project/catapult,SummerLW/Perf-Insight-Report,catapult-project/catapult-csm,catapult-project/catapult,benschmaus/catapult,catapult-project/catapult,sahiljain/catapult,benschmaus/catapult,benschmaus/catapult,sahiljain/catapult
c721ba7badc0b980d9c58822b5c0b626b1321f1a
grokapi/cli.py
grokapi/cli.py
# -*- coding: utf-8 -*- from queries import Grok def print_monthly_views(site, pages, year, month): grok = Grok(site) for page in pages: result = grok.get_views_for_month(page, year, month) print result['daily_views'] def main(): """ main script. """ from argparse import ArgumentParser description = 'Extract traffic statistics of Wikipedia articles.' parser = ArgumentParser(description=description) parser.add_argument("-l", "--lang", type=str, dest="lang", default="en", required=True, help="Language code for Wikipedia") parser.add_argument("-y", "--year", type=int, dest="year", default="en", required=True, help="Year") parser.add_argument("-m", "--month", type=int, dest="month", default="en", required=True, help="Month") parser.add_argument("page", nargs='*', metavar="PAGE", help='A list of pages') args = parser.parse_args() print_monthly_views(args.lang, args.page, args.year, args.month) if __name__ == '__main__': main()
# -*- coding: utf-8 -*- from queries import Grok def print_monthly_views(site, pages, year, month): grok = Grok(site) for page in pages: result = grok.get_views_for_month(page, year, month) print result['daily_views'] def main(): """ main script. """ from argparse import ArgumentParser description = 'Extract traffic statistics of Wikipedia articles.' parser = ArgumentParser(description=description) parser.add_argument("-l", "--lang", type=str, dest="lang", default="en", required=False, help="Language code for Wikipedia") parser.add_argument("-y", "--year", type=int, dest="year", required=False, help="Year") parser.add_argument("-m", "--month", type=int, dest="month", required=False, help="Month") parser.add_argument("page", nargs='*', metavar="PAGE", help='A list of pages') args = parser.parse_args() print_monthly_views(args.lang, args.page, args.year, args.month) if __name__ == '__main__': main()
Fix default values of Argument Parser
Fix default values of Argument Parser
Python
mit
Commonists/Grokapi
73b7da1a0360f50e660e1983ec02dd5225bde3a3
mitmproxy/platform/__init__.py
mitmproxy/platform/__init__.py
import sys resolver = None if sys.platform == "linux2": from . import linux resolver = linux.Resolver elif sys.platform == "darwin": from . import osx resolver = osx.Resolver elif sys.platform.startswith("freebsd"): from . import osx resolver = osx.Resolver elif sys.platform == "win32": from . import windows resolver = windows.Resolver
import sys import re resolver = None if re.match(r"linux(?:2)?", sys.platform): from . import linux resolver = linux.Resolver elif sys.platform == "darwin": from . import osx resolver = osx.Resolver elif sys.platform.startswith("freebsd"): from . import osx resolver = osx.Resolver elif sys.platform == "win32": from . import windows resolver = windows.Resolver
Fix platform import on Linux using python3
Fix platform import on Linux using python3 Using python3, sys.platform returns "linux" instead of "linux2" using python2. This patch accepts "linux" as well as "linux2".
Python
mit
mosajjal/mitmproxy,vhaupert/mitmproxy,laurmurclar/mitmproxy,Kriechi/mitmproxy,dwfreed/mitmproxy,xaxa89/mitmproxy,ujjwal96/mitmproxy,mosajjal/mitmproxy,Kriechi/mitmproxy,mitmproxy/mitmproxy,mitmproxy/mitmproxy,laurmurclar/mitmproxy,ujjwal96/mitmproxy,vhaupert/mitmproxy,zlorb/mitmproxy,StevenVanAcker/mitmproxy,Kriechi/mitmproxy,ddworken/mitmproxy,mitmproxy/mitmproxy,mosajjal/mitmproxy,ujjwal96/mitmproxy,mhils/mitmproxy,mosajjal/mitmproxy,StevenVanAcker/mitmproxy,xaxa89/mitmproxy,cortesi/mitmproxy,StevenVanAcker/mitmproxy,zlorb/mitmproxy,MatthewShao/mitmproxy,StevenVanAcker/mitmproxy,mhils/mitmproxy,zlorb/mitmproxy,mitmproxy/mitmproxy,dwfreed/mitmproxy,MatthewShao/mitmproxy,jvillacorta/mitmproxy,mhils/mitmproxy,MatthewShao/mitmproxy,Kriechi/mitmproxy,xaxa89/mitmproxy,ddworken/mitmproxy,mitmproxy/mitmproxy,dwfreed/mitmproxy,ddworken/mitmproxy,cortesi/mitmproxy,laurmurclar/mitmproxy,cortesi/mitmproxy,jvillacorta/mitmproxy,dwfreed/mitmproxy,MatthewShao/mitmproxy,mhils/mitmproxy,ujjwal96/mitmproxy,mhils/mitmproxy,vhaupert/mitmproxy,ddworken/mitmproxy,xaxa89/mitmproxy,vhaupert/mitmproxy,cortesi/mitmproxy,jvillacorta/mitmproxy,jvillacorta/mitmproxy,zlorb/mitmproxy,laurmurclar/mitmproxy
d43a08706f3072a0b97d01526ffd0de0d4a4110c
niworkflows/conftest.py
niworkflows/conftest.py
"""py.test configuration""" import os from pathlib import Path import numpy import pytest from .utils.bids import collect_data test_data_env = os.getenv('TEST_DATA_HOME', str(Path.home() / '.cache' / 'stanford-crn')) data_dir = Path(test_data_env) / 'BIDS-examples-1-enh-ds054' @pytest.fixture(autouse=True) def add_np(doctest_namespace): doctest_namespace['np'] = numpy doctest_namespace['os'] = os doctest_namespace['Path'] = Path doctest_namespace['datadir'] = data_dir doctest_namespace['bids_collect_data'] = collect_data @pytest.fixture def testdata_dir(): return data_dir
"""py.test configuration""" import os from pathlib import Path import numpy as np import nibabel as nb import pytest import tempfile from .utils.bids import collect_data test_data_env = os.getenv('TEST_DATA_HOME', str(Path.home() / '.cache' / 'stanford-crn')) data_dir = Path(test_data_env) / 'BIDS-examples-1-enh-ds054' @pytest.fixture(autouse=True) def add_np(doctest_namespace): doctest_namespace['np'] = np doctest_namespace['os'] = os doctest_namespace['Path'] = Path doctest_namespace['datadir'] = data_dir doctest_namespace['bids_collect_data'] = collect_data tmpdir = tempfile.TemporaryDirectory() nifti_fname = str(Path(tmpdir.name) / 'test.nii.gz') nb.Nifti1Image(np.random.random((5, 5)).astype('f4'), np.eye(4)).to_filename(nifti_fname) doctest_namespace['nifti_fname'] = nifti_fname yield tmpdir.cleanup() @pytest.fixture def testdata_dir(): return data_dir
Make nifti_fname available to doctests
DOCTEST: Make nifti_fname available to doctests
Python
apache-2.0
oesteban/niworkflows,oesteban/niworkflows,poldracklab/niworkflows,oesteban/niworkflows,poldracklab/niworkflows
e8afa1408618d7dc4e39b84963199dd87c217ef9
app/main/views/buyers.py
app/main/views/buyers.py
from flask import render_template, request, flash from flask_login import login_required from .. import main from ... import data_api_client from ..auth import role_required @main.route('/buyers', methods=['GET']) @login_required @role_required('admin') def find_buyer_by_brief_id(): brief_id = request.args.get('brief_id') try: brief = data_api_client.get_brief(brief_id).get('briefs') except: flash('no_brief', 'error') return render_template( "view_buyers.html", users=list(), title=None, brief_id=brief_id ), 404 users = brief.get('users') title = brief.get('title') return render_template( "view_buyers.html", users=users, title=title, brief_id=brief_id )
from flask import render_template, request, flash from flask_login import login_required from .. import main from ... import data_api_client from ..auth import role_required @main.route('/buyers', methods=['GET']) @login_required @role_required('admin') def find_buyer_by_brief_id(): brief_id = request.args.get('brief_id') try: brief = data_api_client.get_brief(brief_id).get('briefs') except: flash('no_brief', 'error') return render_template( "view_buyers.html", users=list(), brief_id=brief_id ), 404 users = brief.get('users') title = brief.get('title') return render_template( "view_buyers.html", users=users, title=title, brief_id=brief_id )
Remove unnecessary variable from route
Remove unnecessary variable from route Jinja will set any variable it can't find to None, so the title variable is unnecessary.
Python
mit
alphagov/digitalmarketplace-admin-frontend,alphagov/digitalmarketplace-admin-frontend,alphagov/digitalmarketplace-admin-frontend,alphagov/digitalmarketplace-admin-frontend
7f08e4c9fd370e375ad8e174a98478c0281ecb6e
tools/manifest/tool.py
tools/manifest/tool.py
import os import time import pwd from .utils import effective_user class Tool(object): USER_NAME_PATTERN = 'tools.%s' class InvalidToolException(Exception): pass def __init__(self, name, username, uid, gid, home): self.name = name self.uid = uid self.gid = gid self.username = username self.home = home @classmethod def from_name(cls, name): """ Create a Tool instance from a tool name """ username = Tool.USER_NAME_PATTERN % (name, ) try: user_info = pwd.getpwnam(username) except KeyError: # No such user was found raise Tool.InvalidToolException("No tool with name %s" % (name, )) if user_info.pw_uid < 50000: raise Tool.InvalidToolException("uid of tools should be < 50000, %s has uid %s" % (name, user_info.pw_uid)) return cls(name, user_info.pw_name, user_info.pw_uid, user_info.pw_gid, user_info.pw_dir) def log(self, message): """ Write to a log file in the tool's homedir """ log_line = "%s %s" % (time.asctime(), message) log_path = os.path.join(self.home, 'service.log') with effective_user(self.uid, self.gid): with open(log_path, 'a') as f: f.write(log_line + '\n')
import os import datetime import pwd from .utils import effective_user class Tool(object): USER_NAME_PATTERN = 'tools.%s' class InvalidToolException(Exception): pass def __init__(self, name, username, uid, gid, home): self.name = name self.uid = uid self.gid = gid self.username = username self.home = home @classmethod def from_name(cls, name): """ Create a Tool instance from a tool name """ username = Tool.USER_NAME_PATTERN % (name, ) try: user_info = pwd.getpwnam(username) except KeyError: # No such user was found raise Tool.InvalidToolException("No tool with name %s" % (name, )) if user_info.pw_uid < 50000: raise Tool.InvalidToolException("uid of tools should be < 50000, %s has uid %s" % (name, user_info.pw_uid)) return cls(name, user_info.pw_name, user_info.pw_uid, user_info.pw_gid, user_info.pw_dir) def log(self, message): """ Write to a log file in the tool's homedir """ log_line = "%s %s" % (datetime.datetime.now().isoformat(), message) log_path = os.path.join(self.home, 'service.log') with effective_user(self.uid, self.gid): with open(log_path, 'a') as f: f.write(log_line + '\n')
Use isoformat in datetime logs, rather than asctime
Use isoformat in datetime logs, rather than asctime Change-Id: Ic11a70e28288517b6f174d7066f71a12efd5f4f1
Python
mit
wikimedia/operations-software-tools-manifest
8d0b9da511d55191609ffbd88a8b11afd6ff0367
remedy/radremedy.py
remedy/radremedy.py
#!/usr/bin/env python """ radremedy.py Main web application file. Contains initial setup of database, API, and other components. Also contains the setup of the routes. """ from flask import Flask, url_for, request, abort from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand from rad.models import db, Resource def create_app(config, models=()): from remedyblueprint import remedy, url_for_other_page app = Flask(__name__) app.config.from_object(config) app.register_blueprint(remedy) # searching configurations app.jinja_env.trim_blocks = True # Register the paging helper method with Jinja2 app.jinja_env.globals['url_for_other_page'] = url_for_other_page db.init_app(app) Migrate(app, db, directory=app.config['MIGRATIONS_DIR']) manager = Manager(app) manager.add_command('db', MigrateCommand) # turning API off for now # from api_manager import init_api_manager # api_manager = init_api_manager(app, db) # map(lambda m: api_manager.create_api(m), models) return app, manager if __name__ == '__main__': app, manager = create_app('config.BaseConfig', (Resource, )) with app.app_context(): manager.run()
#!/usr/bin/env python """ radremedy.py Main web application file. Contains initial setup of database, API, and other components. Also contains the setup of the routes. """ from flask import Flask, url_for, request, abort from flask.ext.script import Manager from flask.ext.migrate import Migrate, MigrateCommand from flask.ext.login import current_user from rad.models import db, Resource def create_app(config, models=()): app = Flask(__name__) app.config.from_object(config) from remedyblueprint import remedy, url_for_other_page app.register_blueprint(remedy) from auth.user_auth import auth, login_manager app.register_blueprint(auth) login_manager.init_app(app) # searching configurations app.jinja_env.trim_blocks = True # Register the paging helper method with Jinja2 app.jinja_env.globals['url_for_other_page'] = url_for_other_page app.jinja_env.globals['logged_in'] = lambda : not current_user.is_anonymous() db.init_app(app) Migrate(app, db, directory=app.config['MIGRATIONS_DIR']) manager = Manager(app) manager.add_command('db', MigrateCommand) # turning API off for now # from api_manager import init_api_manager # api_manager = init_api_manager(app, db) # map(lambda m: api_manager.create_api(m), models) return app, manager if __name__ == '__main__': application, manager = create_app('config.BaseConfig', (Resource, )) with application.app_context(): manager.run()
Move around imports and not shadow app
Move around imports and not shadow app
Python
mpl-2.0
radioprotector/radremedy,radioprotector/radremedy,radioprotector/radremedy,AllieDeford/radremedy,AllieDeford/radremedy,radremedy/radremedy,radremedy/radremedy,radremedy/radremedy,AllieDeford/radremedy,radioprotector/radremedy,radremedy/radremedy
608325c33cb2d446b89c263ba0bb02ced5c4ffe8
portal/views.py
portal/views.py
import csv from django.shortcuts import render from django.http import HttpResponse from . import services def index(request): data = services.overview() return render(request, 'index.html', data) def meter_runs(request): """Render the table of exported MeterRun results in html""" data = services.meterruns_export() return render(request, 'project_run_table.html', data) def csv_export(request): """Return a dump of all the MeterRuns in CSV form""" response = HttpResponse(content_type="text/csv") response["Content-Disposition"] = 'attachment; filename="meter_runs.csv"' writer = csv.writer(response) writer.writerow(['First row', 'Foo', 'Bar']) return response
import csv from django.shortcuts import render from django.http import HttpResponse from . import services def index(request): data = services.overview() return render(request, 'index.html', data) def meter_runs(request): """Render the table of exported MeterRun results in html""" data = services.meterruns_export() return render(request, 'project_run_table.html', data) def csv_export(request): """Return a dump of all the MeterRuns in CSV form""" response = HttpResponse(content_type="text/csv") response["Content-Disposition"] = 'attachment; filename="meter_runs.csv"' data = services.meterruns_export() writer = csv.DictWriter(response, fieldnames=data['headers']) writer.writeheader() for meter_run in data['meter_runs']: writer.writerow(meter_run) return response
Use the meterrun_export service to power csv export
Use the meterrun_export service to power csv export
Python
mit
impactlab/oeem-energy-datastore,impactlab/oeem-energy-datastore,impactlab/oeem-energy-datastore
cca2bd0d4cfb14dbf85e4275fd9d064b9ffa08cc
urlgetters/yle_urls.py
urlgetters/yle_urls.py
import requests url = "https://ua.api.yle.fi/graphql?app_id=8d7303fe&app_key=105875199ef3a1f7e0fbf7e2834b2dc&query={uutisetMostRecentNews:articleList(publisher:YLE_UUTISET,limit:100,offset:0,coverage:NATIONAL){meta{count,total,remaining},items{fullUrl,properties}}}" i = 0 while True: url = "https://ua.api.yle.fi/graphql?app_id=8d7303fe&app_key=105875199ef3a1f7e0fbf7e2834b2dc&query={uutisetMostRecentNews:articleList(publisher:YLE_UUTISET,limit:100,offset:" + str( i * 100 ) + ",coverage:NATIONAL){meta{count,total,remaining},items{fullUrl,properties}}}" r = requests.get( url ) r = r.json() d = r['data'] items = d['uutisetMostRecentNews']['items'] for item in items: print item['fullUrl'] if d['meta']['remaining'] < 100: return i += 1
import requests url = "https://ua.api.yle.fi/graphql?app_id=8d7303fe&app_key=105875199ef3a1f7e0fbf7e2834b2dc&query={uutisetMostRecentNews:articleList(publisher:YLE_UUTISET,limit:100,offset:0,coverage:NATIONAL){meta{count,total,remaining},items{fullUrl,properties}}}" i = 0 while True: url = "https://ua.api.yle.fi/graphql?app_id=8d7303fe&app_key=105875199ef3a1f7e0fbf7e2834b2dc&query={uutisetMostRecentNews:articleList(publisher:YLE_UUTISET,limit:100,offset:" + str( i * 100 ) + ",coverage:NATIONAL){meta{count,total,remaining},items{fullUrl,properties}}}" r = requests.get( url ) r = r.json() d = r['data']['uutisetMostRecentNews'] items = d['items'] for item in items: print item['fullUrl'] if d['meta']['remaining'] < 100: break i += 1
Make script run and fix all typos
Make script run and fix all typos
Python
mit
HIIT/mediacollection
54d67ce544e95ecb58a62062ffe50fcd95db6f09
sso/apps.py
sso/apps.py
from django.apps import AppConfig class SsoConfig(AppConfig): name = 'sso' github_client_id = '844189c44c56ff04e727' github_client_secret = '0bfecee7a78ee0e800b6bff85b08c140b91be4cc'
import json import os.path from django.apps import AppConfig from fmproject import settings class SsoConfig(AppConfig): base_config = json.load( open(os.path.join(settings.BASE_DIR, 'fmproject', 'config.json')) ) name = 'sso' github_client_id = base_config['github']['client_id'] github_client_secret = base_config['github']['client_secret']
Load github config from external file
Load github config from external file
Python
mit
favoritemedium/sso-prototype,favoritemedium/sso-prototype
37170b156e6a284d5e5df671875070a3fcac9310
commands/join.py
commands/join.py
from CommandTemplate import CommandTemplate from IrcMessage import IrcMessage class Command(CommandTemplate): triggers = ['join'] helptext = "Makes me join another channel, if I'm allowed to at least" def execute(self, message): """ :type message: IrcMessage """ replytext = "" if message.messagePartsLength < 1: replytext = "Please provide a channel for me to join" else: channel = message.messageParts[0] if channel.replace('#', '') not in message.bot.factory.settings['allowedChannels'] and not message.bot.factory.isUserAdmin(message.user, message.userNickname, message.userAddress): replytext = "I'm sorry, I'm not allowed to go there. Please ask my admin(s) for permission" else: replytext = "All right, I'll go to {}. See you there!".format(channel) message.bot.join(channel) message.reply(replytext, "say")
from CommandTemplate import CommandTemplate from IrcMessage import IrcMessage class Command(CommandTemplate): triggers = ['join'] helptext = "Makes me join another channel, if I'm allowed to at least" def execute(self, message): """ :type message: IrcMessage """ replytext = "" if message.messagePartsLength < 1: replytext = "Please provide a channel for me to join" else: channel = message.messageParts[0].lower() if channel.startswith('#'): channel = channel.lstrip('#') if '#' + channel in message.bot.channelsUserList: replytext = "I'm already there, waiting for you. You're welcome!" elif channel not in message.bot.factory.settings['allowedChannels'] and not message.bot.factory.isUserAdmin(message.user, message.userNickname, message.userAddress): replytext = "I'm sorry, I'm not allowed to go there. Please ask my admin(s) for permission" else: replytext = "All right, I'll go to #{}. See you there!".format(channel) message.bot.join(channel) message.reply(replytext, "say")
Check if we're already in the channel; Improved parameter parsing
[Join] Check if we're already in the channel; Improved parameter parsing
Python
mit
Didero/DideRobot
b282c54ebaaae13aa8b81f2380cdc20acaa9fc69
lab/gendata.py
lab/gendata.py
import random import time from coverage.data import CoverageJsonData from coverage.sqldata import CoverageSqliteData NUM_FILES = 1000 NUM_LINES = 1000 def gen_data(cdata): rnd = random.Random() rnd.seed(17) def linenos(num_lines, prob): return (n for n in range(num_lines) if random.random() < prob) start = time.time() for i in range(NUM_FILES): filename = f"/src/foo/project/file{i}.py" line_data = { filename: dict.fromkeys(linenos(NUM_LINES, .6)) } cdata.add_lines(line_data) cdata.write() end = time.time() delta = end - start return delta class DummyData: def add_lines(self, line_data): return def write(self): return overhead = gen_data(DummyData()) jtime = gen_data(CoverageJsonData("gendata.json")) - overhead stime = gen_data(CoverageSqliteData("gendata.db")) - overhead print(f"Overhead: {overhead:.3f}s") print(f"JSON: {jtime:.3f}s") print(f"SQLite: {stime:.3f}s") print(f"{stime / jtime:.3f}x slower")
# Run some timing tests of JsonData vs SqliteData. import random import time from coverage.data import CoverageJsonData from coverage.sqldata import CoverageSqliteData NUM_FILES = 1000 NUM_LINES = 1000 def gen_data(cdata): rnd = random.Random() rnd.seed(17) def linenos(num_lines, prob): return (n for n in range(num_lines) if random.random() < prob) start = time.time() for i in range(NUM_FILES): filename = "/src/foo/project/file{i}.py".format(i=i) line_data = { filename: dict.fromkeys(linenos(NUM_LINES, .6)) } cdata.add_lines(line_data) cdata.write() end = time.time() delta = end - start return delta class DummyData: def add_lines(self, line_data): return def write(self): return overhead = gen_data(DummyData()) jtime = gen_data(CoverageJsonData("gendata.json")) - overhead stime = gen_data(CoverageSqliteData("gendata.db")) - overhead print("Overhead: {overhead:.3f}s".format(overhead=overhead)) print("JSON: {jtime:.3f}s".format(jtime=jtime)) print("SQLite: {stime:.3f}s".format(stime=stime)) print("{slower:.3f}x slower".format(slower=stime/jtime))
Make it run on PyPy for time tests there
Make it run on PyPy for time tests there
Python
apache-2.0
hugovk/coveragepy,nedbat/coveragepy,hugovk/coveragepy,nedbat/coveragepy,hugovk/coveragepy,nedbat/coveragepy,hugovk/coveragepy,hugovk/coveragepy,nedbat/coveragepy,nedbat/coveragepy
ba9386fc7c14be6335896e1d888c822db972dfe1
indra/java_vm.py
indra/java_vm.py
"""Handles all imports from jnius to prevent conflicts resulting from attempts to set JVM options while the VM is already running.""" import os import warnings import jnius_config if '-Xmx4g' not in jnius_config.get_options(): if not jnius_config.vm_running: jnius_config.add_options('-Xmx4g') else: warnings.warn("Couldn't set memory limit for Java VM because the VM " "is already running.") path_here = os.path.dirname(os.path.realpath(__file__)) cp = path_here + '/biopax/jars/paxtools.jar' cp_existing = os.environ.get('CLASSPATH') print 'before', os.environ.get('CLASSPATH') if cp_existing is not None: os.environ['CLASSPATH'] = cp + ':' + cp_existing else: os.environ['CLASSPATH'] = cp print 'after', os.environ.get('CLASSPATH') from jnius import autoclass, JavaException, cast
"""Handles all imports from jnius to prevent conflicts resulting from attempts to set JVM options while the VM is already running.""" import os import warnings import jnius_config if '-Xmx4g' not in jnius_config.get_options(): if not jnius_config.vm_running: jnius_config.add_options('-Xmx4g') else: warnings.warn("Couldn't set memory limit for Java VM because the VM " "is already running.") path_here = os.path.dirname(os.path.realpath(__file__)) cp = path_here + '/biopax/jars/paxtools.jar' cp_existing = os.environ.get('CLASSPATH') if cp_existing is not None: os.environ['CLASSPATH'] = cp + ':' + cp_existing else: os.environ['CLASSPATH'] = cp from jnius import autoclass, JavaException, cast
Remove messages from Java VM
Remove messages from Java VM
Python
bsd-2-clause
bgyori/indra,johnbachman/belpy,johnbachman/indra,bgyori/indra,sorgerlab/indra,jmuhlich/indra,pvtodorov/indra,johnbachman/belpy,sorgerlab/indra,pvtodorov/indra,jmuhlich/indra,sorgerlab/belpy,sorgerlab/belpy,pvtodorov/indra,johnbachman/belpy,sorgerlab/indra,jmuhlich/indra,bgyori/indra,johnbachman/indra,pvtodorov/indra,johnbachman/indra,sorgerlab/belpy
d66b4be946785d7b9223a0a3497d8ec4a4cebea9
project/settings/production.py
project/settings/production.py
import os from .common import * DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'singlepoint', } } PUBLIC_ROOT = os.path.join(os.sep, 'var', 'www', 'singlepoint', 'public') STATIC_ROOT = os.path.join(PUBLIC_ROOT, 'static') MEDIA_ROOT = os.path.join(PUBLIC_ROOT, 'media') TEMPLATE_LOADERS = ( ('django.template.loaders.cached.Loader', TEMPLATE_LOADERS), ) PREPEND_WWW = False EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASSWORD') EMAIL_HOST = 'mail.trilan.ru' EMAIL_HOST_USER = 'noanswer@trilan.ru' DEFAULT_FROM_EMAIL = 'noanswer@trilan.ru' ALLOWED_HOSTS = ['.singlepointhq.com'] BROKER_URL = 'redis://localhost:6379/0' INSTALLED_APPS += ("djcelery_email",) EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' CELERYD_CONCURRENCY = 2 CELERYD_MAX_TASKS_PER_CHILD = 100
import os from .common import * DATABASES = { 'default': { 'ENGINE': 'django.db.backends.postgresql_psycopg2', 'NAME': 'singlepoint', } } PUBLIC_ROOT = os.path.join(os.sep, 'var', 'www', 'singlepoint', 'public') STATIC_ROOT = os.path.join(PUBLIC_ROOT, 'static') MEDIA_ROOT = os.path.join(PUBLIC_ROOT, 'media') TEMPLATE_LOADERS = ( ('django.template.loaders.cached.Loader', TEMPLATE_LOADERS), ) PREPEND_WWW = False EMAIL_HOST_PASSWORD = os.environ.get('EMAIL_PASSWORD') EMAIL_HOST = 'mail.trilan.ru' EMAIL_HOST_USER = 'noanswer@trilan.ru' DEFAULT_FROM_EMAIL = 'noanswer@trilan.ru' ALLOWED_HOSTS = ['.singlepointhq.com'] BROKER_URL = 'redis://localhost:6379/0' INSTALLED_APPS += ("djcelery", "djcelery_email",) EMAIL_BACKEND = 'djcelery_email.backends.CeleryEmailBackend' CELERYD_CONCURRENCY = 2 CELERYD_MAX_TASKS_PER_CHILD = 100
Add django celery to installed apps
Add django celery to installed apps
Python
mit
xobb1t/ddash2013,xobb1t/ddash2013
88fd32be09bc20ce734f272b7d3a54a71958e6b4
energy/models.py
energy/models.py
from sqlalchemy import create_engine from sqlalchemy.sql import text import arrow def get_energy_chart_data(meterId, start_date="2016-09-01", end_date="2016-10-01"): """ Return json object for flot chart """ engine = create_engine('sqlite:///../data/'+ str(meterId) + '.db', echo=True) conn = engine.connect() query = """SELECT DATE_M, Ch1 FROM INTERVAL_READINGS WHERE DATE_M >= DATE(:x) AND DATE_M < DATE(:y) ORDER BY DATE_M ASC """ s = text(query) data = conn.execute(s, x=start_date, y=end_date).fetchall() chartdata = {} chartdata['label'] = 'Energy Profile' chartdata['consumption'] = [] for row in data: dTime = arrow.get(row[0]) ts = int(dTime.timestamp * 1000) chartdata['consumption'].append([ts, row[1]]) return chartdata
from sqlalchemy import create_engine from sqlalchemy import MetaData, Table, Column, DateTime, Float, between from sqlalchemy.sql import select, text import arrow metadata = MetaData() meter_readings = Table('interval_readings', metadata, Column('reading_date', DateTime, primary_key=True), Column('ch1', Float, nullable=False), ) def get_energy_chart_data(meterId, start_date="2016-09-01", end_date="2016-10-01"): """ Return json object for flot chart """ engine = create_engine('sqlite:///../data/'+ str(meterId) + '.db', echo=True) conn = engine.connect() s = select([meter_readings]).where(between(meter_readings.c.reading_date, start_date, end_date)) data = conn.execute(s).fetchall() chartdata = {} chartdata['label'] = 'Energy Profile' chartdata['consumption'] = [] for row in data: dTime = arrow.get(row[0]) ts = int(dTime.timestamp * 1000) chartdata['consumption'].append([ts, row[1]]) return chartdata
Use sqlalchemy to generate query
Use sqlalchemy to generate query
Python
agpl-3.0
aguinane/energyusage,aguinane/energyusage,aguinane/energyusage,aguinane/energyusage
ea1389d6dfb0060cda8d194079aacc900bbf56ae
simple_graph.py
simple_graph.py
#!/usr/bin/env python from __future__ import print_function from __future__ import unicode_literals class Graph(object): ''' Create an empty graph. ''' def __init__(self): self.graph = {} return def nodes(): return nodes def edges(): return edges def add_node(self, node): self.graph.setdefault(node, []) return def add_edge(self, node1, node2): return def del_node(self, node): try: del self.graph[node] except KeyError: raise KeyError('node not in graph') def has_node(self, node): return node in self.graph def neighbors(self, node): return self.graph[node] def adjecent(self, node1, node2): if node2 in self.graph[node1] or node1 in self.graph[node2]: return True else: return False
#!/usr/bin/env python from __future__ import print_function from __future__ import unicode_literals class Graph(object): ''' Create an empty graph. ''' def __init__(self): self.graph = {} return def nodes(self): return self.graph.keys() def edges(self): edge_list = [] for key, value in self.graph(): for item in value: edge_list.append((key, item)) return edge_list def add_node(self, node): self.graph.setdefault(node, []) def add_edge(self, node1, node2): if node1 in self.graph: self.graph.append(node2) else: self.graph[node1] = node2 def del_node(self, node): try: del self.graph[node] except KeyError: raise KeyError('node not in graph') def has_node(self, node): return node in self.graph def neighbors(self, node): return self.graph[node] def adjecent(self, node1, node2): if node2 in self.graph[node1] or node1 in self.graph[node2]: return True else: return False
Add functions for adding a node, an edge, and defining a node
Add functions for adding a node, an edge, and defining a node
Python
mit
constanthatz/data-structures
2d50e06c7e55c19e3055d555d78fac699c61104d
tests/integration/test_os_signals.py
tests/integration/test_os_signals.py
import os import signal import diesel state = {'triggered':False} def waiter(): diesel.signal(signal.SIGUSR1) state['triggered'] = True def test_can_wait_on_os_signals(): # Start our Loop that will wait on USR1 diesel.fork(waiter) # Let execution switch to the newly spawned loop diesel.sleep() # We haven't sent the signal, so the state should not be triggered assert not state['triggered'] # Send the USR1 signal os.kill(os.getpid(), signal.SIGUSR1) # Again, force a switch so the waiter can act on the signal diesel.sleep() # Now that we're back, the waiter should have triggered the state assert state['triggered']
import os import signal import diesel from diesel.util.event import Countdown state = {'triggered':False} def waiter(): diesel.signal(signal.SIGUSR1) state['triggered'] = True def test_can_wait_on_os_signals(): # Start our Loop that will wait on USR1 diesel.fork(waiter) # Let execution switch to the newly spawned loop diesel.sleep() # We haven't sent the signal, so the state should not be triggered assert not state['triggered'] # Send the USR1 signal os.kill(os.getpid(), signal.SIGUSR1) # Again, force a switch so the waiter can act on the signal diesel.sleep() # Now that we're back, the waiter should have triggered the state assert state['triggered'] def test_multiple_signal_waiters(): N_WAITERS = 5 c = Countdown(N_WAITERS) def mwaiter(): diesel.signal(signal.SIGUSR1) c.tick() for i in xrange(N_WAITERS): diesel.fork(mwaiter) diesel.sleep() os.kill(os.getpid(), signal.SIGUSR1) evt, data = diesel.first(sleep=1, waits=[c]) assert evt is c, "all waiters were not triggered!"
Test for multiple waiters on a signal
Test for multiple waiters on a signal
Python
bsd-3-clause
dieseldev/diesel
931ae68671abef1fedde46d585a4057b24ecbb04
reinforcement-learning/play.py
reinforcement-learning/play.py
"""Load the trained q table and make actions based on that. """ import time import env import rl rl.load_q() env.make("pygame") while True: env.reset() for _ in range(15): if env.done: break action = rl.choose_action(rl.table[env.object[0]]) env.action(action) time.sleep(0.03) env.render()
"""Load the trained q table and make actions based on that. """ import time import env import rl rl.load_q() env.make("pygame") while True: env.reset() for _ in range(15): if env.done: break action = rl.choose_action(env.player, "test") env.action(action) time.sleep(0.03) env.render()
Update to newest version of rl.py.
Update to newest version of rl.py.
Python
mit
danieloconell/Louis
bb6b6b46860f6e03abc4ac9c47751fe4309f0e17
md2pdf/core.py
md2pdf/core.py
# -*- coding: utf-8 -*- from markdown2 import markdown, markdown_path from weasyprint import HTML, CSS from .exceptions import ValidationError __title__ = 'md2pdf' __version__ = '0.2.1' __author__ = 'Julien Maupetit' __license__ = 'MIT' __copyright__ = 'Copyright 2013 Julien Maupetit' def md2pdf(pdf_file_path, md_content=None, md_file_path=None, css_file_path=None): """ Convert markdown file to pdf with styles """ # Convert markdown to html raw_html = "" extras = ["cuddled-lists"] if md_file_path: raw_html = markdown_path(md_file_path, extras=extras) elif md_content: raw_html = markdown(md_content, extras=extras) if not len(raw_html): raise ValidationError('Input markdown seems empty') # Weasyprint HTML object html = HTML(string=raw_html) # Get styles css = [] if css_file_path: css.append(CSS(filename=css_file_path)) # Generate PDF html.write_pdf(pdf_file_path, stylesheets=css) return
# -*- coding: utf-8 -*- from markdown2 import markdown, markdown_path from weasyprint import HTML, CSS from .exceptions import ValidationError __title__ = 'md2pdf' __version__ = '0.2.1' __author__ = 'Julien Maupetit' __license__ = 'MIT' __copyright__ = 'Copyright 2013 Julien Maupetit' def md2pdf(pdf_file_path, md_content=None, md_file_path=None, css_file_path=None, base_url=None): """ Convert markdown file to pdf with styles """ # Convert markdown to html raw_html = "" extras = ["cuddled-lists"] if md_file_path: raw_html = markdown_path(md_file_path, extras=extras) elif md_content: raw_html = markdown(md_content, extras=extras) if not len(raw_html): raise ValidationError('Input markdown seems empty') # Weasyprint HTML object html = HTML(string=raw_html, base_url=base_url) # Get styles css = [] if css_file_path: css.append(CSS(filename=css_file_path)) # Generate PDF html.write_pdf(pdf_file_path, stylesheets=css) return
Allow to add a base url to find media
Allow to add a base url to find media
Python
mit
jmaupetit/md2pdf
0e19f960b2234fcd9711f123526f8de507ed2d99
src/registry.py
src/registry.py
from .formatter import * class FormatterRegistry(): def __init__(self): self.__formatters = [] def populate(self): self.__formatters = [ ClangFormat(), ElmFormat(), GoFormat(), JavaScriptFormat(), JsonFormat(), PythonFormat(), RustFormat(), TerraformFormat() ] @property def all(self): return self.__formatters @property def enabled(self): return [x for x in self.all if x.format_on_save] def find(self, predicate, default=None): return next((x for x in self.all if predicate(x)), default) def by_view(self, view): source = view.scope_name(0).split(' ')[0].split('.')[1] return self.find(lambda x: source in x.sources) def by_name(self, name): return self.find(lambda x: x.name == name)
from .formatter import * class FormatterRegistry(): def __init__(self): self.__formatters = [] self.__formatter_source_map = {} def populate(self): self.__formatters = [ ClangFormat(), ElmFormat(), GoFormat(), JavaScriptFormat(), JsonFormat(), PythonFormat(), RustFormat(), TerraformFormat() ] self.__formatter_source_map = dict((source, formatter) for formatter in self.__formatters for source in formatter.sources) @property def all(self): return self.__formatters @property def enabled(self): return [x for x in self.all if x.format_on_save] def by_view(self, view): source = view.scope_name(0).split(' ')[0].split('.')[1] return self.__formatter_source_map.get(source) def by_name(self, name): return next((x for x in self.all if x.name == name))
Speed up lookup of formatter by source type
Speed up lookup of formatter by source type
Python
mit
Rypac/sublime-format