commit
stringlengths
40
40
old_file
stringlengths
4
150
new_file
stringlengths
4
150
old_contents
stringlengths
0
3.26k
new_contents
stringlengths
1
4.43k
subject
stringlengths
15
501
message
stringlengths
15
4.06k
lang
stringclasses
4 values
license
stringclasses
13 values
repos
stringlengths
5
91.5k
diff
stringlengths
0
4.35k
f2bf249f4ea954b318819bd5976584eedba35517
pytablereader/__init__.py
pytablereader/__init__.py
# encoding: utf-8 """ .. codeauthor:: Tsuyoshi Hombashi <[email protected]> """ from __future__ import absolute_import from tabledata import DataError, InvalidHeaderNameError, InvalidTableNameError from .__version__ import __author__, __copyright__, __email__, __license__, __version__ from ._constant import PatternMatch from ._logger import logger, set_log_level, set_logger from .csv.core import CsvTableFileLoader, CsvTableTextLoader from .error import ( APIError, HTTPError, InvalidFilePathError, LoaderNotFoundError, OpenError, PathError, ProxyError, PypandocImportError, UrlError, ValidationError, ) from .html.core import HtmlTableFileLoader, HtmlTableTextLoader from .json.core import JsonTableDictLoader, JsonTableFileLoader, JsonTableTextLoader from .jsonlines.core import JsonLinesTableFileLoader, JsonLinesTableTextLoader from .loadermanager import TableFileLoader, TableUrlLoader from .ltsv.core import LtsvTableFileLoader, LtsvTableTextLoader from .markdown.core import MarkdownTableFileLoader, MarkdownTableTextLoader from .mediawiki.core import MediaWikiTableFileLoader, MediaWikiTableTextLoader from .spreadsheet.excelloader import ExcelTableFileLoader from .spreadsheet.gsloader import GoogleSheetsTableLoader from .sqlite.core import SqliteFileLoader from .tsv.core import TsvTableFileLoader, TsvTableTextLoader
# encoding: utf-8 """ .. codeauthor:: Tsuyoshi Hombashi <[email protected]> """ from __future__ import absolute_import from tabledata import DataError, InvalidHeaderNameError, InvalidTableNameError from .__version__ import __author__, __copyright__, __email__, __license__, __version__ from ._constant import PatternMatch from ._logger import set_log_level, set_logger from .csv.core import CsvTableFileLoader, CsvTableTextLoader from .error import ( APIError, HTTPError, InvalidFilePathError, LoaderNotFoundError, OpenError, PathError, ProxyError, PypandocImportError, UrlError, ValidationError, ) from .html.core import HtmlTableFileLoader, HtmlTableTextLoader from .json.core import JsonTableDictLoader, JsonTableFileLoader, JsonTableTextLoader from .jsonlines.core import JsonLinesTableFileLoader, JsonLinesTableTextLoader from .loadermanager import TableFileLoader, TableUrlLoader from .ltsv.core import LtsvTableFileLoader, LtsvTableTextLoader from .markdown.core import MarkdownTableFileLoader, MarkdownTableTextLoader from .mediawiki.core import MediaWikiTableFileLoader, MediaWikiTableTextLoader from .spreadsheet.excelloader import ExcelTableFileLoader from .spreadsheet.gsloader import GoogleSheetsTableLoader from .sqlite.core import SqliteFileLoader from .tsv.core import TsvTableFileLoader, TsvTableTextLoader
Hide logger from outside of the package
Hide logger from outside of the package
Python
mit
thombashi/pytablereader,thombashi/pytablereader,thombashi/pytablereader
--- +++ @@ -10,7 +10,7 @@ from .__version__ import __author__, __copyright__, __email__, __license__, __version__ from ._constant import PatternMatch -from ._logger import logger, set_log_level, set_logger +from ._logger import set_log_level, set_logger from .csv.core import CsvTableFileLoader, CsvTableTextLoader from .error import ( APIError,
57f3bec127148c80a9304194e5c3c8a3d3f3bae2
tests/scoring_engine/web/views/test_scoreboard.py
tests/scoring_engine/web/views/test_scoreboard.py
from tests.scoring_engine.web.web_test import WebTest class TestScoreboard(WebTest): def test_home(self): # todo fix this up!!!! # resp = self.client.get('/scoreboard') # assert resp.status_code == 200 # lazy AF assert 1 == 1
from tests.scoring_engine.web.web_test import WebTest from tests.scoring_engine.helpers import populate_sample_data class TestScoreboard(WebTest): def test_scoreboard(self): populate_sample_data(self.session) resp = self.client.get('/scoreboard') assert resp.status_code == 200 assert self.mock_obj.call_args[0][0] == 'scoreboard.html' assert self.mock_obj.call_args[1]['team_labels'] == ['Blue Team 1'] assert self.mock_obj.call_args[1]['team_scores'] == [100] assert self.mock_obj.call_args[1]['round_labels'] == ['Round 0', 'Round 1', 'Round 2'] assert 'scores_colors' in self.mock_obj.call_args[1] assert self.mock_obj.call_args[1]['team_data'][1]['data'] == [0, 100, 100] assert self.mock_obj.call_args[1]['team_data'][1]['label'] == 'Blue Team 1' assert 'color' in self.mock_obj.call_args[1]['team_data'][1]
Add tests for scoreboard view
Add tests for scoreboard view
Python
mit
pwnbus/scoring_engine,pwnbus/scoring_engine,pwnbus/scoring_engine,pwnbus/scoring_engine
--- +++ @@ -1,11 +1,18 @@ from tests.scoring_engine.web.web_test import WebTest +from tests.scoring_engine.helpers import populate_sample_data class TestScoreboard(WebTest): - def test_home(self): - # todo fix this up!!!! - # resp = self.client.get('/scoreboard') - # assert resp.status_code == 200 - # lazy AF - assert 1 == 1 + def test_scoreboard(self): + populate_sample_data(self.session) + resp = self.client.get('/scoreboard') + assert resp.status_code == 200 + assert self.mock_obj.call_args[0][0] == 'scoreboard.html' + assert self.mock_obj.call_args[1]['team_labels'] == ['Blue Team 1'] + assert self.mock_obj.call_args[1]['team_scores'] == [100] + assert self.mock_obj.call_args[1]['round_labels'] == ['Round 0', 'Round 1', 'Round 2'] + assert 'scores_colors' in self.mock_obj.call_args[1] + assert self.mock_obj.call_args[1]['team_data'][1]['data'] == [0, 100, 100] + assert self.mock_obj.call_args[1]['team_data'][1]['label'] == 'Blue Team 1' + assert 'color' in self.mock_obj.call_args[1]['team_data'][1]
ebac72a3753205d3e45041c6db636a378187e3cf
pylua/tests/test_compiled.py
pylua/tests/test_compiled.py
import os import subprocess from pylua.tests.helpers import test_file class TestCompiled(object): """ Tests compiled binary """ def test_addition(self, capsys): f = test_file(src=""" -- short add x = 10 y = 5 z = y + y + x print(z) print(z+y) --a = 100+y lx = 1234567890 ly = 99999999 print(lx+ly) --print(lx+1234567890) """, suffix=".l" ) out = subprocess.check_output(['bin/pylua', f.name]) assert out == "20.000000\n25.000000\n1334567889.000000\n"
import os import subprocess from pylua.tests.helpers import test_file class TestCompiled(object): """ Tests compiled binary """ PYLUA_BIN = os.path.join(os.path.dirname(os.path.abspath(__file__)), ('../../bin/pylua')) def test_addition(self, capsys): f = test_file(src=""" -- short add x = 10 y = 5 z = y + y + x print(z) print(z+y) --a = 100+y lx = 1234567890 ly = 99999999 print(lx+ly) --print(lx+1234567890) """, suffix=".l" ) out = subprocess.check_output([TestCompiled.PYLUA_BIN, f.name]) assert out == "20.000000\n25.000000\n1334567889.000000\n"
Use absolute path for lua binary in tests
Use absolute path for lua binary in tests
Python
bsd-3-clause
fhahn/luna,fhahn/luna
--- +++ @@ -8,6 +8,8 @@ """ Tests compiled binary """ + + PYLUA_BIN = os.path.join(os.path.dirname(os.path.abspath(__file__)), ('../../bin/pylua')) def test_addition(self, capsys): f = test_file(src=""" @@ -25,5 +27,5 @@ --print(lx+1234567890) """, suffix=".l" ) - out = subprocess.check_output(['bin/pylua', f.name]) + out = subprocess.check_output([TestCompiled.PYLUA_BIN, f.name]) assert out == "20.000000\n25.000000\n1334567889.000000\n"
5577b2a20a98aa232f5591a46269e5ee6c88070d
MyMoment.py
MyMoment.py
import datetime #Humanize time in milliseconds #Reference: http://stackoverflow.com/questions/26276906/python-convert-seconds-from-epoch-time-into-human-readable-time def HTM(aa): a = int(aa) b = int(datetime.datetime.now().strftime("%s")) c = b - a days = c // 86400 hours = c // 3600 % 24 minutes = c // 60 % 60 seconds = c % 60 ago = "ago" if (days > 0): return ( str(days) + " days " + ago) elif (hours > 0): return (str(hours) + " hours " + ago) elif (minutes > 0): return ( str(minutes) + " minutes " + ago) elif (seconds > 0): return (str(seconds) + " seconds " + ago) else: return (a) #Error #http://www.epochconverter.com/ #1/6/2015, 8:19:34 AM PST -> 23 hours ago #print HTM(1420561174000/1000)
import datetime from time import gmtime, strftime import pytz #Humanize time in milliseconds #Reference: http://stackoverflow.com/questions/26276906/python-convert-seconds-from-epoch-time-into-human-readable-time #http://www.epochconverter.com/ #1/6/2015, 8:19:34 AM PST -> 23 hours ago #print HTM(1420561174000/1000) def HTM(aa): a = int(aa) b = int(datetime.datetime.now().strftime("%s")) c = b - a days = c // 86400 hours = c // 3600 % 24 minutes = c // 60 % 60 seconds = c % 60 ago = "ago" if (days > 0): return ( str(days) + " days " + ago) elif (hours > 0): return (str(hours) + " hours " + ago) elif (minutes > 0): return ( str(minutes) + " minutes " + ago) elif (seconds > 0): return (str(seconds) + " seconds " + ago) else: return (a) #Error #My Timestamp used in logfile def MT(): fmt = '%Y-%m-%d %H:%M:%S' return (datetime.datetime.now(pytz.timezone("America/Los_Angeles")).strftime(fmt)) #My Timestamp for filename def FT(): fmt = '%d%b%Y-%H%M%S' return ( datetime.datetime.now(pytz.timezone("America/Los_Angeles")).strftime(fmt) )
Add functions to generate timestamp for logfiles & filenames; use localtimezone
Add functions to generate timestamp for logfiles & filenames; use localtimezone
Python
mit
harishvc/githubanalytics,harishvc/githubanalytics,harishvc/githubanalytics
--- +++ @@ -1,7 +1,13 @@ import datetime +from time import gmtime, strftime +import pytz #Humanize time in milliseconds #Reference: http://stackoverflow.com/questions/26276906/python-convert-seconds-from-epoch-time-into-human-readable-time +#http://www.epochconverter.com/ +#1/6/2015, 8:19:34 AM PST -> 23 hours ago +#print HTM(1420561174000/1000) + def HTM(aa): a = int(aa) b = int(datetime.datetime.now().strftime("%s")) @@ -18,6 +24,12 @@ else: return (a) #Error -#http://www.epochconverter.com/ -#1/6/2015, 8:19:34 AM PST -> 23 hours ago -#print HTM(1420561174000/1000) +#My Timestamp used in logfile +def MT(): + fmt = '%Y-%m-%d %H:%M:%S' + return (datetime.datetime.now(pytz.timezone("America/Los_Angeles")).strftime(fmt)) + +#My Timestamp for filename +def FT(): + fmt = '%d%b%Y-%H%M%S' + return ( datetime.datetime.now(pytz.timezone("America/Los_Angeles")).strftime(fmt) )
5cf17b6a46a3d4bbf4cecb65e4b9ef43066869d9
feincms/templatetags/applicationcontent_tags.py
feincms/templatetags/applicationcontent_tags.py
from django import template # backwards compatibility import from feincms.templatetags.fragment_tags import fragment, get_fragment, has_fragment register = template.Library() register.tag(fragment) register.tag(get_fragment) register.filter(has_fragment) @register.simple_tag def feincms_render_region_appcontent(page, region, request): """Render only the application content for the region This allows template authors to choose whether their page behaves differently when displaying embedded application subpages by doing something like this:: {% if not in_appcontent_subpage %} {% feincms_render_region feincms_page "main" request %} {% else %} {% feincms_render_region_appcontent feincms_page "main" request %} {% endif %} """ from feincms.content.application.models import ApplicationContent from feincms.templatetags.feincms_tags import _render_content return u''.join(_render_content(content, request=request) for content in\ getattr(page.content, region) if isinstance(content, ApplicationContent))
from django import template # backwards compatibility import from feincms.templatetags.fragment_tags import fragment, get_fragment, has_fragment register = template.Library() register.tag(fragment) register.tag(get_fragment) register.filter(has_fragment) @register.simple_tag def feincms_render_region_appcontent(page, region, request): """Render only the application content for the region This allows template authors to choose whether their page behaves differently when displaying embedded application subpages by doing something like this:: {% if not in_appcontent_subpage %} {% feincms_render_region feincms_page "main" request %} {% else %} {% feincms_render_region_appcontent feincms_page "main" request %} {% endif %} """ from feincms.content.application.models import ApplicationContent from feincms.templatetags.feincms_tags import _render_content return u''.join(_render_content(content, request=request) for content in\ page.content.all_of_type(ApplicationContent) if content.region == region)
Use all_of_type instead of isinstance check in feincms_render_region_appcontent
Use all_of_type instead of isinstance check in feincms_render_region_appcontent
Python
bsd-3-clause
feincms/feincms,joshuajonah/feincms,feincms/feincms,matthiask/feincms2-content,matthiask/django-content-editor,michaelkuty/feincms,mjl/feincms,matthiask/feincms2-content,mjl/feincms,matthiask/django-content-editor,matthiask/django-content-editor,michaelkuty/feincms,nickburlett/feincms,matthiask/django-content-editor,joshuajonah/feincms,matthiask/feincms2-content,nickburlett/feincms,pjdelport/feincms,pjdelport/feincms,joshuajonah/feincms,pjdelport/feincms,michaelkuty/feincms,michaelkuty/feincms,nickburlett/feincms,feincms/feincms,nickburlett/feincms,joshuajonah/feincms,mjl/feincms
--- +++ @@ -28,4 +28,4 @@ from feincms.templatetags.feincms_tags import _render_content return u''.join(_render_content(content, request=request) for content in\ - getattr(page.content, region) if isinstance(content, ApplicationContent)) + page.content.all_of_type(ApplicationContent) if content.region == region)
b457eac63690deba408c4b5bdc1db179347f43da
postgres/fields/uuid_field.py
postgres/fields/uuid_field.py
from __future__ import unicode_literals import uuid from django.core.exceptions import ValidationError from django.db import models from django.utils import six from django.utils.translation import ugettext_lazy as _ from psycopg2.extras import register_uuid register_uuid() class UUIDField(six.with_metaclass(models.SubfieldBase, models.Field)): """ We can make use of psycopg2's uuid handling: that means everything at the database end will be a uuid. We also make sure that values assigned to this field on a model will automatically be cast to UUID. """ description = "UUID" default_error_messages = { 'invalid': _("'%(value)s' is not a valid UUID."), } def get_internal_type(self): return 'UUIDField' def db_type(self, connection): return 'uuid' def to_python(self, value): if isinstance(value, six.string_types): try: return uuid.UUID(value) except ValueError: raise ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value} ) return value
from __future__ import unicode_literals import uuid from django.core.exceptions import ValidationError from django.db import models from django.utils import six from django.utils.translation import ugettext_lazy as _ from psycopg2.extras import register_uuid register_uuid() class UUIDField(six.with_metaclass(models.SubfieldBase, models.Field)): """ We can make use of psycopg2's uuid handling: that means everything at the database end will be a uuid. We also make sure that values assigned to this field on a model will automatically be cast to UUID. """ description = "UUID" default_error_messages = { 'invalid': _("'%(value)s' is not a valid UUID."), } def __init__(self, **kwargs): kwargs['max_length'] = 36 super(UUIDField, self).__init__(**kwargs) def get_internal_type(self): return 'UUIDField' def db_type(self, connection): return 'uuid' def to_python(self, value): if not value: return None if isinstance(value, six.string_types): try: return uuid.UUID(value) except ValueError: raise ValidationError( self.error_messages['invalid'], code='invalid', params={'value': value} ) return value
Make UUIDField have a fixed max-length
Make UUIDField have a fixed max-length
Python
bsd-3-clause
wlanslovenija/django-postgres
--- +++ @@ -25,6 +25,10 @@ 'invalid': _("'%(value)s' is not a valid UUID."), } + def __init__(self, **kwargs): + kwargs['max_length'] = 36 + super(UUIDField, self).__init__(**kwargs) + def get_internal_type(self): return 'UUIDField' @@ -32,6 +36,9 @@ return 'uuid' def to_python(self, value): + if not value: + return None + if isinstance(value, six.string_types): try: return uuid.UUID(value)
89fe38163426efe02da92974bac369538ab5532f
elmextensions/__init__.py
elmextensions/__init__.py
from .sortedlist import * from .embeddedterminal import * from .aboutwindow import * from .fileselector import * from .tabbedbox import * from .StandardButton import * from .StandardPopup import * from .SearchableList import *
from .sortedlist import * from .embeddedterminal import * from .aboutwindow import * from .fileselector import * from .fontselector import * from .tabbedbox import * from .StandardButton import * from .StandardPopup import * from .SearchableList import * __copyright__ = "Copyright 2015-2017 Jeff Hoogland" __license__ = "BSD-3-clause" # the version number: major, minor, micro, releaselevel, and serial. __version__ = "0.2.1rc.2" version_string = __version__
Access to module level information
Access to module level information
Python
bsd-3-clause
JeffHoogland/python-elm-extensions
--- +++ @@ -2,7 +2,15 @@ from .embeddedterminal import * from .aboutwindow import * from .fileselector import * +from .fontselector import * from .tabbedbox import * from .StandardButton import * from .StandardPopup import * from .SearchableList import * + +__copyright__ = "Copyright 2015-2017 Jeff Hoogland" +__license__ = "BSD-3-clause" + +# the version number: major, minor, micro, releaselevel, and serial. +__version__ = "0.2.1rc.2" +version_string = __version__
f517442097b6ae12eb13b16f2fa6ca40a00b9998
__init__.py
__init__.py
from .features import Giraffe_Feature_Base from .features import Aligned_Feature
from .features import Giraffe_Feature_Base from .features import Aligned_Feature from .features import Feature_Type_Choices
Move Feature_Type_Choices to toplevel name sapce
Move Feature_Type_Choices to toplevel name sapce
Python
mit
benjiec/giraffe-features
--- +++ @@ -1,2 +1,3 @@ from .features import Giraffe_Feature_Base from .features import Aligned_Feature +from .features import Feature_Type_Choices
0830f131b50d9679e6b2097febc7913bc09e5132
mopidy_scrobbler/__init__.py
mopidy_scrobbler/__init__.py
import pathlib from mopidy import config, ext __version__ = "1.2.1" class Extension(ext.Extension): dist_name = "Mopidy-Scrobbler" ext_name = "scrobbler" version = __version__ def get_default_config(self): return config.read(pathlib.Path(__file__).parent / "ext.conf") def get_config_schema(self): schema = super().get_config_schema() schema["username"] = config.String() schema["password"] = config.Secret() return schema def setup(self, registry): from .frontend import ScrobblerFrontend registry.add("frontend", ScrobblerFrontend)
import pathlib import pkg_resources from mopidy import config, ext __version__ = pkg_resources.get_distribution("Mopidy-Scrobbler").version class Extension(ext.Extension): dist_name = "Mopidy-Scrobbler" ext_name = "scrobbler" version = __version__ def get_default_config(self): return config.read(pathlib.Path(__file__).parent / "ext.conf") def get_config_schema(self): schema = super().get_config_schema() schema["username"] = config.String() schema["password"] = config.Secret() return schema def setup(self, registry): from .frontend import ScrobblerFrontend registry.add("frontend", ScrobblerFrontend)
Use pkg_resources to read version
Use pkg_resources to read version
Python
apache-2.0
mopidy/mopidy-scrobbler
--- +++ @@ -1,8 +1,10 @@ import pathlib + +import pkg_resources from mopidy import config, ext -__version__ = "1.2.1" +__version__ = pkg_resources.get_distribution("Mopidy-Scrobbler").version class Extension(ext.Extension):
48ffd37eb826edb78750652628145a924053b204
website/wsgi.py
website/wsgi.py
""" WSGI config for classicalguitar project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "classicalguitar.settings") from django.core.wsgi import get_wsgi_application from dj_static import Cling application = Cling(get_wsgi_application())
""" WSGI config for website project. It exposes the WSGI callable as a module-level variable named ``application``. For more information on this file, see https://docs.djangoproject.com/en/1.7/howto/deployment/wsgi/ """ import os os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings") from django.core.wsgi import get_wsgi_application from dj_static import Cling application = Cling(get_wsgi_application())
Correct some remaining classical guitar refs
Correct some remaining classical guitar refs
Python
bsd-3-clause
chrisguitarguy/GuitarSocieties.org,chrisguitarguy/GuitarSocieties.org
--- +++ @@ -1,5 +1,5 @@ """ -WSGI config for classicalguitar project. +WSGI config for website project. It exposes the WSGI callable as a module-level variable named ``application``. @@ -8,7 +8,7 @@ """ import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "classicalguitar.settings") +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "website.settings") from django.core.wsgi import get_wsgi_application from dj_static import Cling
5a8788222d9a5765bf66a2c93eed25ca7879c856
__init__.py
__init__.py
import inspect import sys if sys.version_info[0] == 2: from .python2 import httplib2 else: from .python3 import httplib2 globals().update(inspect.getmembers(httplib2))
import os import sys path = os.path.dirname(__file__)+os.path.sep+'python'+str(sys.version_info[0]) sys.path.insert(0, path) del sys.modules['httplib2'] import httplib2
Rewrite python version dependent import
Rewrite python version dependent import The top level of this external includes a __init__.py so that it may be imported with only 'externals' in sys.path. However it copies the contents of the python version dependent httplib2 code, resulting in module level variables appearing in two different namespaces. As a result, regarding bug 66161, the 'httplib2.debuglevel' modified in pywikibot code is a different variable to the 'httplib2.debuglevel' used by the httplib2 module. Instead of copying the python version dependent httplib2, re-import the python version dependent httplib2. Change-Id: Ic520505545a5f50f669a01375b253426ecad15ed
Python
mit
jayvdb/httplib2,wikimedia/pywikibot-externals-httplib2,jayvdb/httplib2,wikimedia/pywikibot-externals-httplib2
--- +++ @@ -1,7 +1,7 @@ -import inspect +import os import sys -if sys.version_info[0] == 2: - from .python2 import httplib2 -else: - from .python3 import httplib2 -globals().update(inspect.getmembers(httplib2)) + +path = os.path.dirname(__file__)+os.path.sep+'python'+str(sys.version_info[0]) +sys.path.insert(0, path) +del sys.modules['httplib2'] +import httplib2
2b2e0b180393af779c7d303a1a3162febe098639
permuta/misc/union_find.py
permuta/misc/union_find.py
class UnionFind(object): def __init__(self, n): self.p = [-1]*n self.leaders = set( i for i in range(n) ) def find(self, x): if self.p[x] < 0: return x self.p[x] = self.find(self.p[x]) return self.p[x] def size(self, x): return -self.p[self.find(x)] def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.size(x) > self.size(y): x,y = y,x self.p[y] += self.p[x] self.p[x] = y self.leaders.remove(x)
class UnionFind(object): """A collection of distjoint sets.""" def __init__(self, n = 0): """Creates a collection of n disjoint unit sets.""" self.p = [-1]*n self.leaders = set( i for i in range(n) ) def find(self, x): """Return the identifier of a representative element for the set containing the element with identifier x.""" if self.p[x] < 0: return x self.p[x] = self.find(self.p[x]) return self.p[x] def size(self, x): """Return the number of elements in the set containing the element with identifier x.""" return -self.p[self.find(x)] def unite(self, x, y): """Unite the two sets containing the elements with identifiers x and y, respectively.""" x = self.find(x) y = self.find(y) if x == y: return if self.size(x) > self.size(y): x,y = y,x self.p[y] += self.p[x] self.p[x] = y self.leaders.remove(x) def add(self): """Add a unit set containing a new element to the collection, and return the identifier of the new element.""" nid = len(self.p) self.p.append(nid) return nid
Document UnionFind and implement add function
Document UnionFind and implement add function
Python
bsd-3-clause
PermutaTriangle/Permuta
--- +++ @@ -1,19 +1,28 @@ class UnionFind(object): - def __init__(self, n): + """A collection of distjoint sets.""" + + def __init__(self, n = 0): + """Creates a collection of n disjoint unit sets.""" self.p = [-1]*n self.leaders = set( i for i in range(n) ) def find(self, x): + """Return the identifier of a representative element for the set + containing the element with identifier x.""" if self.p[x] < 0: return x self.p[x] = self.find(self.p[x]) return self.p[x] def size(self, x): + """Return the number of elements in the set containing the element with + identifier x.""" return -self.p[self.find(x)] def unite(self, x, y): + """Unite the two sets containing the elements with identifiers x and y, + respectively.""" x = self.find(x) y = self.find(y) if x == y: @@ -24,3 +33,10 @@ self.p[x] = y self.leaders.remove(x) + def add(self): + """Add a unit set containing a new element to the collection, and + return the identifier of the new element.""" + nid = len(self.p) + self.p.append(nid) + return nid +
40e96e99dc8538ae3b5e5a95d9c6d81ec656ad6c
dash2012/auth/views.py
dash2012/auth/views.py
from django.http import HttpResponseRedirect from django.shortcuts import render from django.core.urlresolvers import reverse from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout from django.contrib.auth.decorators import login_required from cloudfish.models import Cloud def login(r): c = {} if r.POST: username = r.POST['username'] password = r.POST['password'] user = authenticate(username=username, password=password) if user is not None: auth_login(r, user) if not Cloud.objects.filter(account=user).exists(): return HttpResponseRedirect(reverse('connect-view')) return HttpResponseRedirect(reverse('myservers-view')) c['errors'] = "Login failed, please try again" return render(r, 'auth.html', c) def logout(request): auth_logout(request) return HttpResponseRedirect(reverse('index-view')) @login_required def connect(request): return render(request, 'connect.html')
from django.http import HttpResponseRedirect from django.shortcuts import render from django.core.urlresolvers import reverse from django.contrib.auth import authenticate, login as auth_login, logout as auth_logout from django.contrib.auth.decorators import login_required from cloudfish.models import Cloud def login(r): c = {} if r.POST: username = r.POST['username'] password = r.POST['password'] user = authenticate(username=username, password=password) if user is not None: auth_login(r, user) if not Cloud.objects.filter(account=user).exists(): return HttpResponseRedirect(reverse('connect-view')) # If we have at least one cloud, put its data in the user session. r.session['clouds'] = {} connected_clouds = Cloud.objects.filter(user=user) for cloud in connected_clouds: raise Exception() r.session['clouds'][cloud.type] = cloud.decode_auth_data(salt=password) return HttpResponseRedirect(reverse('myservers-view')) else: c['errors'] = "Login failed, please try again" return render(r, 'auth.html', c) def logout(request): auth_logout(request) return HttpResponseRedirect(reverse('index-view')) @login_required def connect(request): return render(request, 'connect.html')
Fix erros msg in login view
Fix erros msg in login view
Python
bsd-3-clause
losmiserables/djangodash2012,losmiserables/djangodash2012
--- +++ @@ -18,9 +18,17 @@ if not Cloud.objects.filter(account=user).exists(): return HttpResponseRedirect(reverse('connect-view')) + # If we have at least one cloud, put its data in the user session. + r.session['clouds'] = {} + + connected_clouds = Cloud.objects.filter(user=user) + for cloud in connected_clouds: + raise Exception() + r.session['clouds'][cloud.type] = cloud.decode_auth_data(salt=password) return HttpResponseRedirect(reverse('myservers-view')) + else: + c['errors'] = "Login failed, please try again" - c['errors'] = "Login failed, please try again" return render(r, 'auth.html', c)
01c5b53ba16a95ab77918d30dfa3a63f2ef2707f
var/spack/repos/builtin/packages/libxcb/package.py
var/spack/repos/builtin/packages/libxcb/package.py
from spack import * class Libxcb(Package): """The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.""" homepage = "http://xcb.freedesktop.org/" url = "http://xcb.freedesktop.org/dist/libxcb-1.11.tar.gz" version('1.11', '1698dd837d7e6e94d029dbe8b3a82deb') version('1.11.1', '118623c15a96b08622603a71d8789bf3') depends_on("python") depends_on("xcb-proto") def install(self, spec, prefix): configure("--prefix=%s" % prefix) make() make("install")
from spack import * class Libxcb(Package): """The X protocol C-language Binding (XCB) is a replacement for Xlib featuring a small footprint, latency hiding, direct access to the protocol, improved threading support, and extensibility.""" homepage = "http://xcb.freedesktop.org/" url = "http://xcb.freedesktop.org/dist/libxcb-1.11.tar.gz" version('1.11', '1698dd837d7e6e94d029dbe8b3a82deb') version('1.11.1', '118623c15a96b08622603a71d8789bf3') depends_on("python") depends_on("xcb-proto") def patch(self): filter_file('typedef struct xcb_auth_info_t {', 'typedef struct {', 'src/xcb.h') def install(self, spec, prefix): configure("--prefix=%s" % prefix) make() make("install")
Make libxcb compile with gcc 4.9.
Make libxcb compile with gcc 4.9.
Python
lgpl-2.1
krafczyk/spack,krafczyk/spack,mfherbst/spack,skosukhin/spack,tmerrick1/spack,iulian787/spack,EmreAtes/spack,lgarren/spack,EmreAtes/spack,matthiasdiener/spack,lgarren/spack,TheTimmy/spack,LLNL/spack,mfherbst/spack,lgarren/spack,iulian787/spack,skosukhin/spack,LLNL/spack,LLNL/spack,mfherbst/spack,skosukhin/spack,matthiasdiener/spack,lgarren/spack,matthiasdiener/spack,TheTimmy/spack,TheTimmy/spack,TheTimmy/spack,skosukhin/spack,iulian787/spack,mfherbst/spack,LLNL/spack,skosukhin/spack,tmerrick1/spack,krafczyk/spack,EmreAtes/spack,matthiasdiener/spack,EmreAtes/spack,tmerrick1/spack,mfherbst/spack,TheTimmy/spack,tmerrick1/spack,EmreAtes/spack,LLNL/spack,lgarren/spack,krafczyk/spack,matthiasdiener/spack,iulian787/spack,krafczyk/spack,tmerrick1/spack,iulian787/spack
--- +++ @@ -1,9 +1,9 @@ from spack import * class Libxcb(Package): - """The X protocol C-language Binding (XCB) is a replacement - for Xlib featuring a small footprint, latency hiding, direct - access to the protocol, improved threading support, and + """The X protocol C-language Binding (XCB) is a replacement + for Xlib featuring a small footprint, latency hiding, direct + access to the protocol, improved threading support, and extensibility.""" homepage = "http://xcb.freedesktop.org/" @@ -14,6 +14,10 @@ depends_on("python") depends_on("xcb-proto") + def patch(self): + filter_file('typedef struct xcb_auth_info_t {', 'typedef struct {', 'src/xcb.h') + + def install(self, spec, prefix): configure("--prefix=%s" % prefix)
79e68ca4b377f479d7eb557879b3450134efaf16
ydf/yaml_ext.py
ydf/yaml_ext.py
""" ydf/yaml_ext ~~~~~~~~~~~~ Contains extensions to existing YAML functionality. """ import collections from ruamel import yaml from ruamel.yaml import resolver __all__ = ['load_all', 'load_all_gen'] class OrderedRoundTripLoader(yaml.RoundTripLoader): """ Extends the default round trip YAML loader to use :class:`~collections.OrderedDict` for mapping types. """ def __init__(self, *args, **kwargs): super(OrderedRoundTripLoader, self).__init__(*args, **kwargs) self.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, self.construct_ordered_mapping) @staticmethod def construct_ordered_mapping(loader, node): loader.flatten_mapping(node) return collections.OrderedDict(loader.construct_pairs(node)) def load_all(stream): """ Load all documents within the given YAML string. :param stream: A valid YAML stream. :return: List that contains all documents found in the YAML stream. """ return list(load_all_gen(stream)) def load_all_gen(stream): """ Load all documents within the given YAML string. :param stream: A valid YAML stream. :return: Generator that yields each document found in the YAML stream. """ return yaml.load_all(stream, OrderedRoundTripLoader)
""" ydf/yaml_ext ~~~~~~~~~~~~ Contains extensions to existing YAML functionality. """ import collections from ruamel import yaml from ruamel.yaml import resolver __all__ = ['load', 'load_all', 'load_all_gen'] class OrderedRoundTripLoader(yaml.RoundTripLoader): """ Extends the default round trip YAML loader to use :class:`~collections.OrderedDict` for mapping types. """ def __init__(self, *args, **kwargs): super(OrderedRoundTripLoader, self).__init__(*args, **kwargs) self.add_constructor(yaml.resolver.BaseResolver.DEFAULT_MAPPING_TAG, self.construct_ordered_mapping) @staticmethod def construct_ordered_mapping(loader, node): loader.flatten_mapping(node) return collections.OrderedDict(loader.construct_pairs(node)) def load(stream): """ Load a single document within the given YAML string. :param stream: A valid YAML stream. :return: An :class:`~collections.OrderedDict` representation of the YAML stream. """ return yaml.load(stream, OrderedRoundTripLoader) def load_all(stream): """ Load all documents within the given YAML string. :param stream: A valid YAML stream. :return: List that contains all documents found in the YAML stream. """ return list(load_all_gen(stream)) def load_all_gen(stream): """ Load all documents within the given YAML string. :param stream: A valid YAML stream. :return: Generator that yields each document found in the YAML stream. """ return yaml.load_all(stream, OrderedRoundTripLoader)
Add YAML load for single document.
Add YAML load for single document.
Python
apache-2.0
ahawker/ydf
--- +++ @@ -11,7 +11,7 @@ from ruamel.yaml import resolver -__all__ = ['load_all', 'load_all_gen'] +__all__ = ['load', 'load_all', 'load_all_gen'] class OrderedRoundTripLoader(yaml.RoundTripLoader): @@ -28,6 +28,16 @@ def construct_ordered_mapping(loader, node): loader.flatten_mapping(node) return collections.OrderedDict(loader.construct_pairs(node)) + + +def load(stream): + """ + Load a single document within the given YAML string. + + :param stream: A valid YAML stream. + :return: An :class:`~collections.OrderedDict` representation of the YAML stream. + """ + return yaml.load(stream, OrderedRoundTripLoader) def load_all(stream):
42f5b2c53474f20fbffbc0b8cdaa4e5b47a4751d
app/wsgi.py
app/wsgi.py
# TODO, figure out how to load gevent monkey patch cleanly in production try: from gevent.monkey import patch_all patch_all() except ImportError: print "unable to apply gevent monkey.patch_all" import os from werkzeug.contrib.fixers import ProxyFix from app import app as application if os.environ.get('SENTRY_DSN'): from raven.contrib.flask import Sentry sentry = Sentry() sentry.init_app(application) application.wsgi_app = ProxyFix(application.wsgi_app)
# TODO, figure out how to load gevent monkey patch cleanly in production # try: # from gevent.monkey import patch_all # patch_all() # except ImportError: # print "unable to apply gevent monkey.patch_all" import os from werkzeug.contrib.fixers import ProxyFix from app import app as application if os.environ.get('SENTRY_DSN'): from raven.contrib.flask import Sentry sentry = Sentry() sentry.init_app(application) application.wsgi_app = ProxyFix(application.wsgi_app)
Comment out gevent until we need it
Comment out gevent until we need it
Python
mit
spacedogXYZ/email-validator,spacedogXYZ/email-validator,spacedogXYZ/email-validator
--- +++ @@ -1,9 +1,9 @@ # TODO, figure out how to load gevent monkey patch cleanly in production -try: - from gevent.monkey import patch_all - patch_all() -except ImportError: - print "unable to apply gevent monkey.patch_all" +# try: +# from gevent.monkey import patch_all +# patch_all() +# except ImportError: +# print "unable to apply gevent monkey.patch_all" import os
785236ca766d832d859c2933389e23fd3d1bea20
djangocms_table/cms_plugins.py
djangocms_table/cms_plugins.py
from django.utils.translation import ugettext_lazy as _ from django.conf import settings from cms.plugin_pool import plugin_pool from cms.plugin_base import CMSPluginBase from models import Table from djangocms_table.forms import TableForm from django.utils import simplejson from djangocms_table.utils import static_url from django.http import HttpResponseRedirect class TablePlugin(CMSPluginBase): model = Table form = TableForm name = _("Table") render_template = "cms/plugins/table.html" text_enabled = True fieldsets = ( (None, { 'fields': ('name',) }), (_('Headers'), { 'fields': (('headers_top', 'headers_left', 'headers_bottom'),) }), (None, { 'fields': ('table_data', 'csv_upload') }) ) def render(self, context, instance, placeholder): try: data = simplejson.loads(instance.table_data) except: data = "error" context.update({ 'name': instance.name, 'data': data, 'instance':instance, }) return context def icon_src(self, instance): return static_url("img/table.png") def response_change(self, request, obj): response = super(TablePlugin, self).response_change(request, obj) if 'csv_upload' in request.FILES.keys(): self.object_successfully_changed = False return response plugin_pool.register_plugin(TablePlugin)
import json from django.utils.translation import ugettext_lazy as _ from django.conf import settings from cms.plugin_pool import plugin_pool from cms.plugin_base import CMSPluginBase from models import Table from djangocms_table.forms import TableForm from djangocms_table.utils import static_url from django.http import HttpResponseRedirect class TablePlugin(CMSPluginBase): model = Table form = TableForm name = _("Table") render_template = "cms/plugins/table.html" text_enabled = True fieldsets = ( (None, { 'fields': ('name',) }), (_('Headers'), { 'fields': (('headers_top', 'headers_left', 'headers_bottom'),) }), (None, { 'fields': ('table_data', 'csv_upload') }) ) def render(self, context, instance, placeholder): try: data = json.loads(instance.table_data) except: data = "error" context.update({ 'name': instance.name, 'data': data, 'instance':instance, }) return context def icon_src(self, instance): return static_url("img/table.png") def response_change(self, request, obj): response = super(TablePlugin, self).response_change(request, obj) if 'csv_upload' in request.FILES.keys(): self.object_successfully_changed = False return response plugin_pool.register_plugin(TablePlugin)
Fix another simplejson deprecation warning
Fix another simplejson deprecation warning
Python
bsd-3-clause
freelancersunion/djangocms-table,freelancersunion/djangocms-table,freelancersunion/djangocms-table,divio/djangocms-table,divio/djangocms-table,divio/djangocms-table
--- +++ @@ -1,10 +1,10 @@ +import json from django.utils.translation import ugettext_lazy as _ from django.conf import settings from cms.plugin_pool import plugin_pool from cms.plugin_base import CMSPluginBase from models import Table from djangocms_table.forms import TableForm -from django.utils import simplejson from djangocms_table.utils import static_url from django.http import HttpResponseRedirect @@ -30,7 +30,7 @@ def render(self, context, instance, placeholder): try: - data = simplejson.loads(instance.table_data) + data = json.loads(instance.table_data) except: data = "error" context.update({
17d54738a57a355fef3e83484162af13ecd2ea63
localore/localore_admin/migrations/0003_auto_20160316_1646.py
localore/localore_admin/migrations/0003_auto_20160316_1646.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('localore_admin', '0002_auto_20160316_1444'), ] run_before = [ ('home', '0002_create_homepage'), ] operations = [ migrations.RenameField( model_name='localoreimage', old_name='alt', new_name='alt_text', ), ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import migrations, models class Migration(migrations.Migration): dependencies = [ ('localore_admin', '0002_auto_20160316_1444'), ] run_before = [ ('home', '0002_create_homepage'), ('people', '0006_auto_20160318_1718'), ] operations = [ migrations.RenameField( model_name='localoreimage', old_name='alt', new_name='alt_text', ), ]
Fix (?) another custom image model migration error
Fix (?) another custom image model migration error
Python
mpl-2.0
ghostwords/localore,ghostwords/localore,ghostwords/localore
--- +++ @@ -12,6 +12,7 @@ run_before = [ ('home', '0002_create_homepage'), + ('people', '0006_auto_20160318_1718'), ] operations = [
6b3f568a6615e9439fc0df0eac68838b6cbda0d9
anti-XSS.py
anti-XSS.py
#!/usr/bin/env python ''' Copyright (c) 2016 anti-XSS developers ''' import sys from lib.core.link import Link from optparse import OptionParser from lib.core.engine import getPage from lib.core.engine import getScript from lib.core.engine import xssScanner from lib.generator.report import gnrReport def main(): parser = OptionParser() parser.add_option('-u', '--url', dest='startUrl', help='Target URL (e.g. \'http://www.site.com/\')') parser.add_option('-d', '--depth', dest='depth', help='The depth you want to scan (default: 2)') (options, args) = parser.parse_args() if options.startUrl: rootLink = Link(options.startUrl, options.startUrl) if options.depth: getPage(rootLink, int(options.depth)) else: getPage(rootLink, 2) getScript() xssScanner() pass if __name__ == '__main__': main()
#!/usr/bin/env python ''' Copyright (c) 2016 anti-XSS developers ''' import sys from lib.core.urlfun import * from lib.core.link import Link from optparse import OptionParser from lib.core.engine import getPage from lib.core.engine import getScript from lib.core.engine import xssScanner from lib.generator.report import gnrReport def main(): parser = OptionParser() parser.add_option('-u', '--url', dest='startUrl', help='Target URL (e.g. \'http://www.site.com/\')') parser.add_option('-d', '--depth', dest='depth', help='The depth you want to scan (default: 2)') (options, args) = parser.parse_args() if options.startUrl: url = initialize(options.startUrl) rootLink = Link(url, url) if options.depth: getPage(rootLink, int(options.depth)) else: getPage(rootLink, 2) getScript() xssScanner() pass if __name__ == '__main__': main()
Add initialization before get url
Add initialization before get url
Python
mit
lewangbtcc/anti-XSS,lewangbtcc/anti-XSS
--- +++ @@ -5,6 +5,8 @@ ''' import sys + +from lib.core.urlfun import * from lib.core.link import Link from optparse import OptionParser @@ -20,7 +22,8 @@ (options, args) = parser.parse_args() if options.startUrl: - rootLink = Link(options.startUrl, options.startUrl) + url = initialize(options.startUrl) + rootLink = Link(url, url) if options.depth: getPage(rootLink, int(options.depth)) else:
19d99f6040d1474feee0f2fb0bda7cb14fbf407c
nose2/tests/unit/test_config.py
nose2/tests/unit/test_config.py
from nose2 import config from nose2.compat import unittest class TestConfigSession(unittest.TestCase): def test_can_create_session(self): config.Session() class TestConfig(unittest.TestCase): def setUp(self): self.conf = config.Config([ ('a', ' 1 '), ('b', ' x\n y '), ('c', '0')]) def test_as_int(self): self.assertEqual(self.conf.as_int('a'), 1) def test_as_str(self): self.assertEqual(self.conf.as_str('a'), '1') self.assertEqual(self.conf.as_str('b'), 'x\n y') self.assertEqual(self.conf.as_str('missing', 'default'), 'default') def test_as_bool(self): self.assertEqual(self.conf.as_bool('a'), True) self.assertEqual(self.conf.as_bool('c'), False) def test_as_float(self): self.assertAlmostEqual(self.conf.as_float('a'), 1.0) def test_as_list(self): self.assertEqual(self.conf.as_list('b'), ['x', 'y'])
from nose2 import config from nose2.compat import unittest class TestConfigSession(unittest.TestCase): def test_can_create_session(self): config.Session() def test_load_plugins_from_module_can_load_plugins(self): class fakemod: pass f = fakemod() class A(events.Plugin): pass f.A = A session = config.Session() session.loadPluginsFromModule(f) assert session.plugins a = session.plugins[0] self.assertEqual(a.session, session) class TestConfig(unittest.TestCase): def setUp(self): self.conf = config.Config([ ('a', ' 1 '), ('b', ' x\n y '), ('c', '0'), ('d', '123')]) def test_as_int(self): self.assertEqual(self.conf.as_int('a'), 1) def test_as_str(self): self.assertEqual(self.conf.as_str('a'), '1') self.assertEqual(self.conf.as_str('b'), 'x\n y') self.assertEqual(self.conf.as_str('missing', 'default'), 'default') def test_as_bool(self): self.assertEqual(self.conf.as_bool('a'), True) self.assertEqual(self.conf.as_bool('c'), False) def test_as_float(self): self.assertAlmostEqual(self.conf.as_float('a'), 1.0) def test_as_list(self): self.assertEqual(self.conf.as_list('b'), ['x', 'y']) self.assertEqual(self.conf.as_list('a'), ['1']) self.assertEqual(self.conf.as_list('d'), ['123'])
Add test for as_list bugfix
Add test for as_list bugfix
Python
bsd-2-clause
ojengwa/nose2,little-dude/nose2,leth/nose2,leth/nose2,ptthiem/nose2,ptthiem/nose2,ezigman/nose2,ojengwa/nose2,ezigman/nose2,little-dude/nose2
--- +++ @@ -6,11 +6,25 @@ def test_can_create_session(self): config.Session() + def test_load_plugins_from_module_can_load_plugins(self): + class fakemod: + pass + f = fakemod() + class A(events.Plugin): + pass + f.A = A + session = config.Session() + session.loadPluginsFromModule(f) + assert session.plugins + a = session.plugins[0] + self.assertEqual(a.session, session) + class TestConfig(unittest.TestCase): def setUp(self): self.conf = config.Config([ - ('a', ' 1 '), ('b', ' x\n y '), ('c', '0')]) + ('a', ' 1 '), ('b', ' x\n y '), ('c', '0'), + ('d', '123')]) def test_as_int(self): self.assertEqual(self.conf.as_int('a'), 1) @@ -29,3 +43,5 @@ def test_as_list(self): self.assertEqual(self.conf.as_list('b'), ['x', 'y']) + self.assertEqual(self.conf.as_list('a'), ['1']) + self.assertEqual(self.conf.as_list('d'), ['123'])
a3df62c7da4aa29ab9977a0307e0634fd43e37e8
pywebfaction/exceptions.py
pywebfaction/exceptions.py
import ast EXCEPTION_TYPE_PREFIX = "<class 'webfaction_api.exceptions." EXCEPTION_TYPE_SUFFIX = "'>" def _parse_exc_type(exc_type): # This is horribly hacky, but there's not a particularly elegant # way to go from the exception type to a string representing that # exception. if not exc_type.startswith(EXCEPTION_TYPE_PREFIX): return None if not exc_type.endswith(EXCEPTION_TYPE_SUFFIX): return None return exc_type[len(EXCEPTION_TYPE_PREFIX):len(EXCEPTION_TYPE_SUFFIX) * -1] def _parse_exc_message(exc_message): if not exc_message: return None message = ast.literal_eval(exc_message) if isinstance(message, list): if not message: return None return message[0] return message class WebFactionFault(Exception): def __init__(self, underlying_fault): self.underlying_fault = underlying_fault exc_type, exc_message = underlying_fault.faultString.split(':', 1) self.exception_type = _parse_exc_type(exc_type) self.exception_message = _parse_exc_message(exc_message)
import ast EXCEPTION_TYPE_PREFIX = "<class 'webfaction_api.exceptions." EXCEPTION_TYPE_SUFFIX = "'>" def _parse_exc_type(exc_type): # This is horribly hacky, but there's not a particularly elegant # way to go from the exception type to a string representing that # exception. if not exc_type.startswith(EXCEPTION_TYPE_PREFIX): return None if not exc_type.endswith(EXCEPTION_TYPE_SUFFIX): return None return exc_type[len(EXCEPTION_TYPE_PREFIX):len(EXCEPTION_TYPE_SUFFIX) * -1] def _parse_exc_message(exc_message): if not exc_message: return None message = ast.literal_eval(exc_message) if isinstance(message, list): if not message: return None return message[0] return message class WebFactionFault(Exception): def __init__(self, underlying): self.underlying_fault = underlying try: exc_type, exc_message = underlying.faultString.split(':', 1) self.exception_type = _parse_exc_type(exc_type) self.exception_message = _parse_exc_message(exc_message) except ValueError: self.exception_type = None self.exception_message = None
Make code immune to bad fault messages
Make code immune to bad fault messages
Python
bsd-3-clause
dominicrodger/pywebfaction,dominicrodger/pywebfaction
--- +++ @@ -33,8 +33,12 @@ class WebFactionFault(Exception): - def __init__(self, underlying_fault): - self.underlying_fault = underlying_fault - exc_type, exc_message = underlying_fault.faultString.split(':', 1) - self.exception_type = _parse_exc_type(exc_type) - self.exception_message = _parse_exc_message(exc_message) + def __init__(self, underlying): + self.underlying_fault = underlying + try: + exc_type, exc_message = underlying.faultString.split(':', 1) + self.exception_type = _parse_exc_type(exc_type) + self.exception_message = _parse_exc_message(exc_message) + except ValueError: + self.exception_type = None + self.exception_message = None
9f345963d1c8dc25818d2cf6716d40e6c90cb615
sentry/client/handlers.py
sentry/client/handlers.py
import logging import sys class SentryHandler(logging.Handler): def emit(self, record): from sentry.client.models import get_client from sentry.client.middleware import SentryLogMiddleware # Fetch the request from a threadlocal variable, if available request = getattr(SentryLogMiddleware.thread, 'request', None) # Avoid typical config issues by overriding loggers behavior if record.name == 'sentry.errors': print >> sys.stderr, "Recursive log message sent to SentryHandler" print >> sys.stderr, record.message return self.format(record) get_client().create_from_record(record, request=request) try: import logbook except ImportError: pass else: class SentryLogbookHandler(logbook.Handler): def emit(self, record): from sentry.client.models import get_client # Avoid typical config issues by overriding loggers behavior if record.name == 'sentry.errors': print >> sys.stderr, "Recursive log message sent to SentryHandler" print >> sys.stderr, record.message return kwargs = dict( message=record.message, level=record.level, logger=record.channel, data=record.extra, ) client = get_client() if record.exc_info: return client.create_from_exception(record.exc_info, **kwargs) return client.create_from_text(**kwargs)
import logging import sys class SentryHandler(logging.Handler): def emit(self, record): from sentry.client.models import get_client from sentry.client.middleware import SentryLogMiddleware # Fetch the request from a threadlocal variable, if available request = getattr(SentryLogMiddleware.thread, 'request', None) self.format(record) # Avoid typical config issues by overriding loggers behavior if record.name == 'sentry.errors': print >> sys.stderr, "Recursive log message sent to SentryHandler" print >> sys.stderr, record.message return get_client().create_from_record(record, request=request) try: import logbook except ImportError: pass else: class SentryLogbookHandler(logbook.Handler): def emit(self, record): from sentry.client.models import get_client self.format(record) # Avoid typical config issues by overriding loggers behavior if record.name == 'sentry.errors': print >> sys.stderr, "Recursive log message sent to SentryHandler" print >> sys.stderr, record.message return kwargs = dict( message=record.message, level=record.level, logger=record.channel, data=record.extra, ) client = get_client() if record.exc_info: return client.create_from_exception(record.exc_info, **kwargs) return client.create_from_text(**kwargs)
Format records before referencing the message attribute
Format records before referencing the message attribute
Python
bsd-3-clause
pauloschilling/sentry,ngonzalvez/sentry,gencer/sentry,camilonova/sentry,NickPresta/sentry,Natim/sentry,dbravender/raven-python,fuziontech/sentry,korealerts1/sentry,jmagnusson/raven-python,imankulov/sentry,felixbuenemann/sentry,songyi199111/sentry,jokey2k/sentry,SilentCircle/sentry,zenefits/sentry,jean/sentry,jbarbuto/raven-python,lopter/raven-python-old,arthurlogilab/raven-python,Natim/sentry,openlabs/raven,nicholasserra/sentry,beni55/sentry,ifduyue/sentry,BuildingLink/sentry,mitsuhiko/raven,1tush/sentry,Goldmund-Wyldebeast-Wunderliebe/raven-python,kevinastone/sentry,jbarbuto/raven-python,looker/sentry,drcapulet/sentry,felixbuenemann/sentry,patrys/opbeat_python,argonemyth/sentry,lepture/raven-python,someonehan/raven-python,BayanGroup/sentry,danriti/raven-python,vperron/sentry,llonchj/sentry,SilentCircle/sentry,jean/sentry,daikeren/opbeat_python,JackDanger/sentry,chayapan/django-sentry,ronaldevers/raven-python,ewdurbin/sentry,imankulov/sentry,ewdurbin/sentry,patrys/opbeat_python,hzy/raven-python,jean/sentry,lepture/raven-python,mitsuhiko/raven,inspirehep/raven-python,WoLpH/django-sentry,Kryz/sentry,akalipetis/raven-python,collective/mr.poe,daevaorn/sentry,inspirehep/raven-python,Kronuz/django-sentry,camilonova/sentry,looker/sentry,tbarbugli/sentry_fork,jmagnusson/raven-python,JTCunning/sentry,songyi199111/sentry,BuildingLink/sentry,jbarbuto/raven-python,mvaled/sentry,pauloschilling/sentry,dbravender/raven-python,looker/sentry,rdio/sentry,zenefits/sentry,tbarbugli/sentry_fork,inspirehep/raven-python,Photonomie/raven-python,alex/raven,jean/sentry,alexm92/sentry,alex/sentry,akheron/raven-python,nicholasserra/sentry,JamesMura/sentry,nikolas/raven-python,chayapan/django-sentry,primepix/django-sentry,kevinastone/sentry,alexm92/sentry,zenefits/sentry,zenefits/sentry,fotinakis/sentry,primepix/django-sentry,BayanGroup/sentry,smarkets/raven-python,percipient/raven-python,arthurlogilab/raven-python,looker/sentry,wong2/sentry,boneyao/sentry,gg7/sentry,daikeren/opbeat_python,wujuguang/sentry,danriti/raven-python,JackDanger/sentry,JamesMura/sentry,gencer/sentry,TedaLIEz/sentry,beni55/sentry,akalipetis/raven-python,kevinlondon/sentry,gencer/sentry,recht/raven-python,songyi199111/sentry,fuziontech/sentry,felixbuenemann/sentry,hongliang5623/sentry,gencer/sentry,TedaLIEz/sentry,ifduyue/sentry,smarkets/raven-python,beniwohli/apm-agent-python,johansteffner/raven-python,hongliang5623/sentry,ticosax/opbeat_python,1tush/sentry,johansteffner/raven-python,Kryz/sentry,zenefits/sentry,mvaled/sentry,ticosax/opbeat_python,beeftornado/sentry,mitsuhiko/sentry,rdio/sentry,johansteffner/raven-python,BuildingLink/sentry,tarkatronic/opbeat_python,JamesMura/sentry,jmp0xf/raven-python,ronaldevers/raven-python,Photonomie/raven-python,NickPresta/sentry,drcapulet/sentry,JackDanger/sentry,ifduyue/sentry,boneyao/sentry,nicholasserra/sentry,beni55/sentry,inspirehep/raven-python,beniwohli/apm-agent-python,percipient/raven-python,patrys/opbeat_python,fuziontech/sentry,percipient/raven-python,mvaled/sentry,Goldmund-Wyldebeast-Wunderliebe/raven-python,getsentry/raven-python,someonehan/raven-python,JamesMura/sentry,fotinakis/sentry,ewdurbin/sentry,wong2/sentry,SilentCircle/sentry,mvaled/sentry,daevaorn/sentry,WoLpH/django-sentry,gg7/sentry,ewdurbin/raven-python,korealerts1/sentry,danriti/raven-python,Kronuz/django-sentry,hzy/raven-python,boneyao/sentry,patrys/opbeat_python,JamesMura/sentry,kevinlondon/sentry,jokey2k/sentry,tarkatronic/opbeat_python,JTCunning/sentry,ifduyue/sentry,jmagnusson/raven-python,korealerts1/sentry,ronaldevers/raven-python,JTCunning/sentry,vperron/sentry,alex/sentry,jbarbuto/raven-python,Natim/sentry,nikolas/raven-python,SilentCircle/sentry,icereval/raven-python,daikeren/opbeat_python,mvaled/sentry,getsentry/raven-python,gencer/sentry,recht/raven-python,BayanGroup/sentry,ifduyue/sentry,akheron/raven-python,smarkets/raven-python,wujuguang/sentry,jmp0xf/raven-python,someonehan/raven-python,BuildingLink/sentry,chayapan/django-sentry,NickPresta/sentry,jmp0xf/raven-python,argonemyth/sentry,pauloschilling/sentry,1tush/sentry,ewdurbin/raven-python,Photonomie/raven-python,icereval/raven-python,jean/sentry,rdio/sentry,drcapulet/sentry,dirtycoder/opbeat_python,imankulov/sentry,nikolas/raven-python,fotinakis/sentry,getsentry/raven-python,akheron/raven-python,mitsuhiko/sentry,arthurlogilab/raven-python,wujuguang/sentry,akalipetis/raven-python,ewdurbin/raven-python,lepture/raven-python,argonemyth/sentry,beeftornado/sentry,llonchj/sentry,alexm92/sentry,primepix/django-sentry,dbravender/raven-python,tarkatronic/opbeat_python,fotinakis/sentry,nikolas/raven-python,ngonzalvez/sentry,TedaLIEz/sentry,smarkets/raven-python,mvaled/sentry,Goldmund-Wyldebeast-Wunderliebe/raven-python,icereval/raven-python,daevaorn/sentry,jokey2k/sentry,BuildingLink/sentry,recht/raven-python,arthurlogilab/raven-python,alex/sentry,Goldmund-Wyldebeast-Wunderliebe/raven-python,gg7/sentry,hzy/raven-python,Kronuz/django-sentry,rdio/sentry,beniwohli/apm-agent-python,daevaorn/sentry,dirtycoder/opbeat_python,tbarbugli/sentry_fork,vperron/sentry,beniwohli/apm-agent-python,kevinastone/sentry,dirtycoder/opbeat_python,NickPresta/sentry,Kryz/sentry,looker/sentry,WoLpH/django-sentry,beeftornado/sentry,icereval/raven-python,camilonova/sentry,ticosax/opbeat_python,kevinlondon/sentry,wong2/sentry,hongliang5623/sentry,llonchj/sentry,ngonzalvez/sentry
--- +++ @@ -9,13 +9,14 @@ # Fetch the request from a threadlocal variable, if available request = getattr(SentryLogMiddleware.thread, 'request', None) + self.format(record) + # Avoid typical config issues by overriding loggers behavior if record.name == 'sentry.errors': print >> sys.stderr, "Recursive log message sent to SentryHandler" print >> sys.stderr, record.message return - self.format(record) get_client().create_from_record(record, request=request) try: @@ -26,6 +27,8 @@ class SentryLogbookHandler(logbook.Handler): def emit(self, record): from sentry.client.models import get_client + + self.format(record) # Avoid typical config issues by overriding loggers behavior if record.name == 'sentry.errors':
e7e21188daba6efe02d44c2cef9c1b48c45c0636
readthedocs/donate/urls.py
readthedocs/donate/urls.py
from django.conf.urls import url, patterns, include from . import views urlpatterns = patterns( '', url(r'^$', views.DonateListView.as_view(), name='donate'), url(r'^contribute/$', views.DonateCreateView.as_view(), name='donate_add'), url(r'^contribute/thanks$', views.DonateSuccessView.as_view(), name='donate_success'), )
from django.conf.urls import url, patterns, include from .views import DonateCreateView from .views import DonateListView from .views import DonateSuccessView urlpatterns = patterns( '', url(r'^$', DonateListView.as_view(), name='donate'), url(r'^contribute/$', DonateCreateView.as_view(), name='donate_add'), url(r'^contribute/thanks$', DonateSuccessView.as_view(), name='donate_success'), )
Resolve linting messages in readthedocs.donate.*
Resolve linting messages in readthedocs.donate.*
Python
mit
mhils/readthedocs.org,wijerasa/readthedocs.org,davidfischer/readthedocs.org,atsuyim/readthedocs.org,CedarLogic/readthedocs.org,istresearch/readthedocs.org,wanghaven/readthedocs.org,atsuyim/readthedocs.org,CedarLogic/readthedocs.org,hach-que/readthedocs.org,mhils/readthedocs.org,kenwang76/readthedocs.org,kenwang76/readthedocs.org,gjtorikian/readthedocs.org,soulshake/readthedocs.org,kenshinthebattosai/readthedocs.org,wijerasa/readthedocs.org,istresearch/readthedocs.org,sunnyzwh/readthedocs.org,mhils/readthedocs.org,davidfischer/readthedocs.org,GovReady/readthedocs.org,kdkeyser/readthedocs.org,LukasBoersma/readthedocs.org,safwanrahman/readthedocs.org,wijerasa/readthedocs.org,Tazer/readthedocs.org,fujita-shintaro/readthedocs.org,techtonik/readthedocs.org,mhils/readthedocs.org,safwanrahman/readthedocs.org,Tazer/readthedocs.org,kenwang76/readthedocs.org,attakei/readthedocs-oauth,kenshinthebattosai/readthedocs.org,clarkperkins/readthedocs.org,safwanrahman/readthedocs.org,VishvajitP/readthedocs.org,wanghaven/readthedocs.org,CedarLogic/readthedocs.org,VishvajitP/readthedocs.org,atsuyim/readthedocs.org,michaelmcandrew/readthedocs.org,attakei/readthedocs-oauth,hach-que/readthedocs.org,titiushko/readthedocs.org,laplaceliu/readthedocs.org,sunnyzwh/readthedocs.org,LukasBoersma/readthedocs.org,kdkeyser/readthedocs.org,sid-kap/readthedocs.org,tddv/readthedocs.org,gjtorikian/readthedocs.org,SteveViss/readthedocs.org,stevepiercy/readthedocs.org,espdev/readthedocs.org,emawind84/readthedocs.org,fujita-shintaro/readthedocs.org,titiushko/readthedocs.org,techtonik/readthedocs.org,asampat3090/readthedocs.org,emawind84/readthedocs.org,pombredanne/readthedocs.org,gjtorikian/readthedocs.org,clarkperkins/readthedocs.org,singingwolfboy/readthedocs.org,asampat3090/readthedocs.org,techtonik/readthedocs.org,Tazer/readthedocs.org,asampat3090/readthedocs.org,kenshinthebattosai/readthedocs.org,istresearch/readthedocs.org,VishvajitP/readthedocs.org,fujita-shintaro/readthedocs.org,istresearch/readthedocs.org,sunnyzwh/readthedocs.org,singingwolfboy/readthedocs.org,pombredanne/readthedocs.org,titiushko/readthedocs.org,espdev/readthedocs.org,rtfd/readthedocs.org,sid-kap/readthedocs.org,kdkeyser/readthedocs.org,emawind84/readthedocs.org,LukasBoersma/readthedocs.org,espdev/readthedocs.org,michaelmcandrew/readthedocs.org,singingwolfboy/readthedocs.org,kdkeyser/readthedocs.org,soulshake/readthedocs.org,CedarLogic/readthedocs.org,stevepiercy/readthedocs.org,atsuyim/readthedocs.org,royalwang/readthedocs.org,safwanrahman/readthedocs.org,kenshinthebattosai/readthedocs.org,sunnyzwh/readthedocs.org,tddv/readthedocs.org,emawind84/readthedocs.org,kenwang76/readthedocs.org,SteveViss/readthedocs.org,michaelmcandrew/readthedocs.org,rtfd/readthedocs.org,royalwang/readthedocs.org,GovReady/readthedocs.org,fujita-shintaro/readthedocs.org,singingwolfboy/readthedocs.org,SteveViss/readthedocs.org,royalwang/readthedocs.org,LukasBoersma/readthedocs.org,attakei/readthedocs-oauth,Tazer/readthedocs.org,wanghaven/readthedocs.org,espdev/readthedocs.org,rtfd/readthedocs.org,GovReady/readthedocs.org,stevepiercy/readthedocs.org,laplaceliu/readthedocs.org,gjtorikian/readthedocs.org,hach-que/readthedocs.org,tddv/readthedocs.org,sid-kap/readthedocs.org,laplaceliu/readthedocs.org,clarkperkins/readthedocs.org,clarkperkins/readthedocs.org,techtonik/readthedocs.org,hach-que/readthedocs.org,stevepiercy/readthedocs.org,attakei/readthedocs-oauth,royalwang/readthedocs.org,davidfischer/readthedocs.org,soulshake/readthedocs.org,espdev/readthedocs.org,wijerasa/readthedocs.org,sid-kap/readthedocs.org,SteveViss/readthedocs.org,laplaceliu/readthedocs.org,titiushko/readthedocs.org,soulshake/readthedocs.org,pombredanne/readthedocs.org,wanghaven/readthedocs.org,michaelmcandrew/readthedocs.org,GovReady/readthedocs.org,asampat3090/readthedocs.org,VishvajitP/readthedocs.org,davidfischer/readthedocs.org,rtfd/readthedocs.org
--- +++ @@ -1,11 +1,13 @@ from django.conf.urls import url, patterns, include -from . import views +from .views import DonateCreateView +from .views import DonateListView +from .views import DonateSuccessView urlpatterns = patterns( '', - url(r'^$', views.DonateListView.as_view(), name='donate'), - url(r'^contribute/$', views.DonateCreateView.as_view(), name='donate_add'), - url(r'^contribute/thanks$', views.DonateSuccessView.as_view(), name='donate_success'), + url(r'^$', DonateListView.as_view(), name='donate'), + url(r'^contribute/$', DonateCreateView.as_view(), name='donate_add'), + url(r'^contribute/thanks$', DonateSuccessView.as_view(), name='donate_success'), )
650e0497c99500810f0fd1fc205e975892b26ff2
ibmcnx/doc/DataSources.py
ibmcnx/doc/DataSources.py
###### # Check ExId (GUID) by Email through JDBC # # Author: Christoph Stoettner # Mail: [email protected] # Documentation: http://scripting101.stoeps.de # # Version: 2.0 # Date: 2014-06-04 # # License: Apache 2.0 # # Check ExId of a User in all Connections Applications import ibmcnx.functions dbs = AdminConfig.list('DataSource', AdminConfig.getid('/Cell:cnxwas1Cell01/')) print dbs # dbs = ['FNOSDS', 'FNGCDDS', 'IBM_FORMS_DATA_SOURCE', 'activities', 'blogs', 'communities', 'dogear', 'files', 'forum', 'homepage', 'metrics', 'mobile', 'news', 'oauth provider', 'profiles', 'search', 'wikis'] # List of all databases to check # # for db in dbs: # t1 = ibmcnx.functions.getDSId( db ) # AdminConfig.show( t1 ) # print '\n\n' # AdminConfig.showall( t1 ) # AdminConfig.showAttribute(t1,'statementCacheSize' ) # AdminConfig.showAttribute(t1,'[statementCacheSize]' )
###### # Check ExId (GUID) by Email through JDBC # # Author: Christoph Stoettner # Mail: [email protected] # Documentation: http://scripting101.stoeps.de # # Version: 2.0 # Date: 2014-06-04 # # License: Apache 2.0 # # Check ExId of a User in all Connections Applications import ibmcnx.functions dbs = AdminConfig.list('DataSource', AdminConfig.getid('/Cell:cnxwas1Cell01/')) print dbs dbs = dbs.split('(')[0] print dbs # dbs = ['FNOSDS', 'FNGCDDS', 'IBM_FORMS_DATA_SOURCE', 'activities', 'blogs', 'communities', 'dogear', 'files', 'forum', 'homepage', 'metrics', 'mobile', 'news', 'oauth provider', 'profiles', 'search', 'wikis'] # List of all databases to check # # for db in dbs: # t1 = ibmcnx.functions.getDSId( db ) # AdminConfig.show( t1 ) # print '\n\n' # AdminConfig.showall( t1 ) # AdminConfig.showAttribute(t1,'statementCacheSize' ) # AdminConfig.showAttribute(t1,'[statementCacheSize]' )
Create documentation of DataSource Settings
8: Create documentation of DataSource Settings Task-Url: http://github.com/stoeps13/ibmcnx2/issues/issue/8
Python
apache-2.0
stoeps13/ibmcnx2,stoeps13/ibmcnx2
--- +++ @@ -16,6 +16,8 @@ dbs = AdminConfig.list('DataSource', AdminConfig.getid('/Cell:cnxwas1Cell01/')) print dbs +dbs = dbs.split('(')[0] +print dbs # dbs = ['FNOSDS', 'FNGCDDS', 'IBM_FORMS_DATA_SOURCE', 'activities', 'blogs', 'communities', 'dogear', 'files', 'forum', 'homepage', 'metrics', 'mobile', 'news', 'oauth provider', 'profiles', 'search', 'wikis'] # List of all databases to check # # for db in dbs:
a4eb952cc2e583d3b7786f5dea101d1e013c8159
services/controllers/utils.py
services/controllers/utils.py
def map_range(x, in_min, in_max, out_min, out_max): out_delta = out_max - out_min in_delta = in_max - in_min return (x - in_min) * out_delta / in_delta + out_min
def lerp(a, b, t): return (1.0 - t) * a + t * b def map_range(x, in_min, in_max, out_min, out_max): out_delta = out_max - out_min in_delta = in_max - in_min return (x - in_min) * out_delta / in_delta + out_min
Add function for linear interpolation (lerp)
Add function for linear interpolation (lerp)
Python
bsd-3-clause
gizmo-cda/g2x-submarine-v2,gizmo-cda/g2x-submarine-v2,gizmo-cda/g2x-submarine-v2,gizmo-cda/g2x-submarine-v2
--- +++ @@ -1,3 +1,7 @@ +def lerp(a, b, t): + return (1.0 - t) * a + t * b + + def map_range(x, in_min, in_max, out_min, out_max): out_delta = out_max - out_min in_delta = in_max - in_min
a509cd74d1e49dd9f9585b8e4c43e88aaf2bc19d
tests/stonemason/service/tileserver/test_tileserver.py
tests/stonemason/service/tileserver/test_tileserver.py
# -*- encoding: utf-8 -*- """ tests.stonemason.service.tileserver.test_tileserver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test interfaces of the tile server application. """ import os import unittest from stonemason.service.tileserver import AppBuilder class TestExample(unittest.TestCase): def setUp(self): os.environ['EXAMPLE_APP_ENV'] = 'dev' app = AppBuilder().build() self.client = app.test_client() def test_app(self): resp = self.client.get('/') self.assertEqual(b'Hello World!', resp.data)
# -*- encoding: utf-8 -*- """ tests.stonemason.service.tileserver.test_tileserver ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Test interfaces of the tile server application. """ import os import unittest from stonemason.service.tileserver import AppBuilder class TestExample(unittest.TestCase): def setUp(self): os.environ['EXAMPLE_APP_MODE'] = 'development' app = AppBuilder().build(config='settings.py') self.client = app.test_client() def test_app(self): resp = self.client.get('/') self.assertEqual(b'Hello World!', resp.data)
Update tests for the test app
TEST: Update tests for the test app
Python
mit
Kotaimen/stonemason,Kotaimen/stonemason
--- +++ @@ -14,9 +14,9 @@ class TestExample(unittest.TestCase): def setUp(self): - os.environ['EXAMPLE_APP_ENV'] = 'dev' + os.environ['EXAMPLE_APP_MODE'] = 'development' - app = AppBuilder().build() + app = AppBuilder().build(config='settings.py') self.client = app.test_client() def test_app(self):
7b66af8bea8e6c25e3c2f88efc22875504e8f87a
openstates/events.py
openstates/events.py
from pupa.scrape import Event from .base import OpenstatesBaseScraper import dateutil.parser dparse = lambda x: dateutil.parser.parse(x) if x else None class OpenstatesEventScraper(OpenstatesBaseScraper): def scrape(self): method = 'events/?state={}&dtstart=1776-07-04'.format(self.state) self.events = self.api(method) for event in self.events: e = Event(name=event['description'], location=event['location'], start_time=dparse(event['when']), end_time=dparse(event['end']),) for source in event['sources']: e.add_source(**source) yield e
from pupa.scrape import Event from .base import OpenstatesBaseScraper import dateutil.parser dparse = lambda x: dateutil.parser.parse(x) if x else None class OpenstatesEventScraper(OpenstatesBaseScraper): def scrape(self): method = 'events/?state={}&dtstart=1776-07-04'.format(self.state) self.events = self.api(method) for event in self.events: e = Event(name=event.pop('description'), classification=event.pop('type'), location=event.pop('location'), timezone=event.pop('timezone'), start_time=dparse(event.pop('when')), end_time=dparse(event.pop('end')),) for source in event.pop('sources'): e.add_source(**source) ignore = ['country', 'level', 'state', 'created_at', 'updated_at', 'session', 'id'] for i in ignore: if i in event: event.pop(i) print(event) assert event == {}, "Unknown fields: %s" % ( ", ".join(event.keys()) ) yield e
Add more keys in; validation
Add more keys in; validation
Python
bsd-3-clause
openstates/billy,sunlightlabs/billy,sunlightlabs/billy,openstates/billy,sunlightlabs/billy,openstates/billy
--- +++ @@ -12,10 +12,26 @@ method = 'events/?state={}&dtstart=1776-07-04'.format(self.state) self.events = self.api(method) for event in self.events: - e = Event(name=event['description'], - location=event['location'], - start_time=dparse(event['when']), - end_time=dparse(event['end']),) - for source in event['sources']: + e = Event(name=event.pop('description'), + classification=event.pop('type'), + location=event.pop('location'), + timezone=event.pop('timezone'), + start_time=dparse(event.pop('when')), + end_time=dparse(event.pop('end')),) + + for source in event.pop('sources'): e.add_source(**source) + + ignore = ['country', 'level', 'state', 'created_at', 'updated_at', + 'session', 'id'] + + for i in ignore: + if i in event: + event.pop(i) + + print(event) + + assert event == {}, "Unknown fields: %s" % ( + ", ".join(event.keys()) + ) yield e
14bd2c0732b5871ac43991a237a8f12a334e982d
sirius/LI_V00/__init__.py
sirius/LI_V00/__init__.py
from . import lattice as _lattice from . import accelerator as _accelerator from . import record_names create_accelerator = accelerator.create_accelerator # -- default accelerator values for LI_V00 -- energy = _lattice._energy single_bunch_charge = _lattice._single_bunch_charge multi_bunch_charge = _lattice._multi_bunch_charge pulse_duration_interval = _lattice._pulse_duration_interval default_optics_mode = _lattice._default_optics_mode.label lattice_version = 'LI_V00' family_data = _lattice._family_data emittance = _lattice._emittance
from . import lattice as _lattice from . import accelerator as _accelerator from . import record_names create_accelerator = accelerator.create_accelerator # -- default accelerator values for LI_V00 -- energy = _lattice._energy single_bunch_charge = _lattice._single_bunch_charge multi_bunch_charge = _lattice._multi_bunch_charge pulse_duration_interval = _lattice._pulse_duration_interval default_optics_mode = _lattice._default_optics_mode.label lattice_version = 'LI_V00' family_data = _lattice._family_data emittance = _lattice._emittance global_coupling = 1.0 # "round" beam
Add parameters of initial beam distribution at LI
Add parameters of initial beam distribution at LI
Python
mit
lnls-fac/sirius
--- +++ @@ -13,4 +13,5 @@ default_optics_mode = _lattice._default_optics_mode.label lattice_version = 'LI_V00' family_data = _lattice._family_data -emittance = _lattice._emittance +emittance = _lattice._emittance +global_coupling = 1.0 # "round" beam
c3ead28e278e2b4e3d44071fb891fa54de46b237
shopping_app/utils/helpers.py
shopping_app/utils/helpers.py
import os import random import string from datetime import date, datetime def random_name(): return ''.join([random.choice(string.ascii_lowercase + string.digits) for n in range(20)]) def json_serial(obj): """JSON serializer for objects not serializable by default json code""" if isinstance(obj, (datetime, date)): return obj.isoformat() raise TypeError("Type %s not serializable" % type(obj)) def secret_key_gen(): filepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/secret.ini' generated_key = ''.join([random.SystemRandom().choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(50)]) with open(filepath, 'w') as secret_file: secret_file.write( '[SECRET_KEY]\nKEY: %(key)s' % dict(key=generated_key) ) print('Find your secret key at %(path)s' % dict(path=filepath))
import os import random import string from datetime import date, datetime def random_name(): return ''.join([random.choice(string.ascii_lowercase + string.digits) for n in range(20)]) def json_serial(obj): """JSON serializer for objects not serializable by default json code""" if isinstance(obj, (datetime, date)): return obj.isoformat() raise TypeError("Type %s not serializable" % type(obj)) def secret_key_gen(): filepath = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + '/secret.ini' generated_key = ''.join([random.SystemRandom().choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(50)]) with open(filepath, 'w') as secret_file: secret_file.write( '[SECRET_KEY]\nKEY: %(key)s' % dict(key=generated_key) ) print('Find your secret key at %(path)s' % dict(path=filepath))
Update generate_secret function to the root of the app
Update generate_secret function to the root of the app
Python
mit
gr1d99/shopping-list,gr1d99/shopping-list,gr1d99/shopping-list
--- +++ @@ -17,7 +17,7 @@ def secret_key_gen(): - filepath = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) + '/secret.ini' + filepath = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) + '/secret.ini' generated_key = ''.join([random.SystemRandom().choice(string.ascii_letters + string.digits + string.punctuation) for _ in range(50)]) with open(filepath, 'w') as secret_file:
22a5985cfd29b87a1215a6a38d5ab07ab19e7508
auth_backends/__init__.py
auth_backends/__init__.py
""" Django authentication backends. These package is designed to be used primarily with Open edX Django projects, but should be compatible with non-edX projects as well. """ __version__ = '2.0.0' # pragma: no cover
""" Django authentication backends. These package is designed to be used primarily with Open edX Django projects, but should be compatible with non-edX projects as well. """ __version__ = '2.0.1' # pragma: no cover
Create new Version for auth-backends for release
Create new Version for auth-backends for release
Python
agpl-3.0
edx/auth-backends
--- +++ @@ -3,4 +3,4 @@ These package is designed to be used primarily with Open edX Django projects, but should be compatible with non-edX projects as well. """ -__version__ = '2.0.0' # pragma: no cover +__version__ = '2.0.1' # pragma: no cover
61448043a039543c38c5ca7b9828792cfc8afbb8
justwatch/justwatchapi.py
justwatch/justwatchapi.py
import requests from babel import Locale class JustWatch: def __init__(self, country='AU', **kwargs): self.kwargs = kwargs self.country = country self.language = Locale.parse('und_{}'.format(self.country)).language def search_for_item(self, **kwargs): if kwargs: self.kwargs = kwargs null = None payload = { "content_types":null, "presentation_types":null, "providers":null, "genres":null, "languages":null, "release_year_from":null, "release_year_until":null, "monetization_types":null, "min_price":null, "max_price":null, "scoring_filter_types":null, "cinema_release":null, "query":null } for key, value in self.kwargs.items(): if key in payload.keys(): payload[key] = value else: print('{} is not a valid keyword'.format(key)) header = {'User-Agent':'JustWatch Python client (github.com/dawoudt/JustWatchAPI)'} api_url = 'https://api.justwatch.com/titles/{}_{}/popular'.format(self.language, self.country) r = requests.post(api_url, json=payload, headers=header) return r.json()
import requests from babel import Locale class JustWatch: def __init__(self, country='AU', **kwargs): self.kwargs = kwargs self.country = country self.language = Locale.parse('und_{}'.format(self.country)).language def search_for_item(self, **kwargs): if kwargs: self.kwargs = kwargs null = None payload = { "content_types":null, "presentation_types":null, "providers":null, "genres":null, "languages":null, "release_year_from":null, "release_year_until":null, "monetization_types":null, "min_price":null, "max_price":null, "scoring_filter_types":null, "cinema_release":null, "query":null } for key, value in self.kwargs.items(): if key in payload.keys(): payload[key] = value else: print('{} is not a valid keyword'.format(key)) header = {'User-Agent':'JustWatch Python client (github.com/dawoudt/JustWatchAPI)'} api_url = 'https://api.justwatch.com/titles/{}_{}/popular'.format(self.language, self.country) r = requests.post(api_url, json=payload, headers=header) # Client should deal with rate-limiting. JustWatch may send a 429 Too Many Requests response. r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200 return r.json()
Check and raise HTTP errors
Check and raise HTTP errors
Python
mit
dawoudt/JustWatchAPI
--- +++ @@ -34,4 +34,8 @@ header = {'User-Agent':'JustWatch Python client (github.com/dawoudt/JustWatchAPI)'} api_url = 'https://api.justwatch.com/titles/{}_{}/popular'.format(self.language, self.country) r = requests.post(api_url, json=payload, headers=header) + + # Client should deal with rate-limiting. JustWatch may send a 429 Too Many Requests response. + r.raise_for_status() # Raises requests.exceptions.HTTPError if r.status_code != 200 + return r.json()
fc70feec85f0b22ebef05b0fa1316214a48a465a
background/config/prod.py
background/config/prod.py
from decouple import config from .base import BaseCeleryConfig class CeleryProduction(BaseCeleryConfig): enable_utc = config('CELERY_ENABLE_UTC', default=True, cast=bool) broker_url = config('CELERY_BROKER_URL') result_backend = config('CELERY_RESULT_BACKEND')
from decouple import config from .base import BaseCeleryConfig REDIS_URL = config('REDIS_URL') class CeleryProduction(BaseCeleryConfig): enable_utc = config('CELERY_ENABLE_UTC', default=True, cast=bool) broker_url = config('CELERY_BROKER_URL', default=REDIS_URL) result_backend = config('CELERY_RESULT_BACKEND', default=REDIS_URL)
Use REDIS_URL by default for Celery
Use REDIS_URL by default for Celery
Python
mit
RaitoBezarius/ryuzu-fb-bot
--- +++ @@ -2,8 +2,12 @@ from .base import BaseCeleryConfig +REDIS_URL = config('REDIS_URL') + class CeleryProduction(BaseCeleryConfig): enable_utc = config('CELERY_ENABLE_UTC', default=True, cast=bool) - broker_url = config('CELERY_BROKER_URL') - result_backend = config('CELERY_RESULT_BACKEND') + broker_url = config('CELERY_BROKER_URL', + default=REDIS_URL) + result_backend = config('CELERY_RESULT_BACKEND', + default=REDIS_URL)
431b8db027ce016a957a744ed38f833031e93070
syncplay/__init__.py
syncplay/__init__.py
version = '1.3.0' milestone = 'Chami' release_number = '5' projectURL = 'http://syncplay.pl/'
version = '1.3.0' milestone = 'Chami' release_number = '6' projectURL = 'http://syncplay.pl/'
Move up to release 6 (1.3.0 Beta 3b)
Move up to release 6 (1.3.0 Beta 3b)
Python
apache-2.0
NeverDecaf/syncplay,alby128/syncplay,alby128/syncplay,Syncplay/syncplay,NeverDecaf/syncplay,Syncplay/syncplay
--- +++ @@ -1,4 +1,4 @@ version = '1.3.0' milestone = 'Chami' -release_number = '5' +release_number = '6' projectURL = 'http://syncplay.pl/'
dd0cef83edbd3849484b7fc0ec5cb6372f99bb3a
batchflow/models/utils.py
batchflow/models/utils.py
""" Auxiliary functions for models """ def unpack_args(args, layer_no, layers_max): """ Return layer parameters """ new_args = {} for arg in args: if isinstance(args[arg], list) and layers_max > 1: if len(args[arg]) >= layers_max: arg_value = args[arg][layer_no] else: arg_value = args[arg] else: arg_value = args[arg] new_args.update({arg: arg_value}) return new_args def unpack_fn_from_config(param, config=None): """ Return params from config """ par = config.get(param) if par is None: return None, {} if isinstance(par, (tuple, list)): if len(par) == 0: par_name = None elif len(par) == 1: par_name, par_args = par[0], {} elif len(par) == 2: par_name, par_args = par else: par_name, par_args = par[0], par[1:] elif isinstance(par, dict): par = par.copy() par_name, par_args = par.pop('name', None), par else: par_name, par_args = par, {} return par_name, par_args
""" Auxiliary functions for models """ def unpack_args(args, layer_no, layers_max): """ Return layer parameters """ new_args = {} for arg in args: if isinstance(args[arg], list): if len(args[arg]) >= layers_max: arg_value = args[arg][layer_no] else: arg_value = args[arg] else: arg_value = args[arg] new_args.update({arg: arg_value}) return new_args def unpack_fn_from_config(param, config=None): """ Return params from config """ par = config.get(param) if par is None: return None, {} if isinstance(par, (tuple, list)): if len(par) == 0: par_name = None elif len(par) == 1: par_name, par_args = par[0], {} elif len(par) == 2: par_name, par_args = par else: par_name, par_args = par[0], par[1:] elif isinstance(par, dict): par = par.copy() par_name, par_args = par.pop('name', None), par else: par_name, par_args = par, {} return par_name, par_args
Allow for 1 arg in a list
Allow for 1 arg in a list
Python
apache-2.0
analysiscenter/dataset
--- +++ @@ -5,7 +5,7 @@ """ Return layer parameters """ new_args = {} for arg in args: - if isinstance(args[arg], list) and layers_max > 1: + if isinstance(args[arg], list): if len(args[arg]) >= layers_max: arg_value = args[arg][layer_no] else:
5c3863fdb366f857fb25b88c2e47508f23660cf3
tests/test_socket.py
tests/test_socket.py
import socket from unittest import TestCase try: from unitetest import mock except ImportError: import mock from routeros_api import api_socket class TestSocketWrapper(TestCase): def test_socket(self): inner = mock.Mock() wrapper = api_socket.SocketWrapper(inner) inner.recv.side_effect = [ socket.error(api_socket.EINTR), 'bytes' ] self.assertEqual(wrapper.receive(5), 'bytes') class TestGetSocket(TestCase): @mock.patch('socket.socket.connect') def test_with_interrupt(self, connect): connect.side_effect = [ socket.error(api_socket.EINTR), None ] api_socket.get_socket('host', 123) connect.assert_has_calls([mock.call(('host', 123)), mock.call(('host', 123))]) @mock.patch('socket.socket.connect') def test_with_other_error(self, connect): connect.side_effect = [ socket.error(1), None ] with self.assertRaises(socket.error): api_socket.get_socket('host', 123) connect.assert_has_calls([mock.call(('host', 123))])
import socket from unittest import TestCase try: from unitetest import mock except ImportError: import mock from routeros_api import api_socket class TestSocketWrapper(TestCase): def test_socket(self): inner = mock.Mock() wrapper = api_socket.SocketWrapper(inner) inner.recv.side_effect = [ socket.error(api_socket.EINTR), 'bytes' ] self.assertEqual(wrapper.receive(5), 'bytes') class TestGetSocket(TestCase): @mock.patch('socket.socket.connect') def test_with_interrupt(self, connect): connect.side_effect = [ socket.error(api_socket.EINTR), None ] api_socket.get_socket('host', 123) connect.assert_has_calls([mock.call(('host', 123)), mock.call(('host', 123))]) @mock.patch('socket.socket.connect') def test_with_other_error(self, connect): connect.side_effect = [ socket.error(1), None ] self.assertRaises(socket.error, api_socket.get_socket, 'host', 123) connect.assert_has_calls([mock.call(('host', 123))])
Fix python2.6 compatibility in tests.
Fix python2.6 compatibility in tests.
Python
mit
kramarz/RouterOS-api,socialwifi/RouterOS-api,pozytywnie/RouterOS-api
--- +++ @@ -36,6 +36,5 @@ socket.error(1), None ] - with self.assertRaises(socket.error): - api_socket.get_socket('host', 123) + self.assertRaises(socket.error, api_socket.get_socket, 'host', 123) connect.assert_has_calls([mock.call(('host', 123))])
8581d3bb9a0066b872dc8daddfde070fdcda7b89
docs/conf.py
docs/conf.py
from __future__ import unicode_literals import os import sys extensions = [] templates_path = [] source_suffix = ".rst" master_doc = "index" project = "django-user-accounts" copyright_holder = "James Tauber and contributors" copyright = "2013, {0}",format(copyright_holder) exclude_patterns = ["_build"] pygments_style = "sphinx" html_theme = "default" htmlhelp_basename = "{0}doc".format(project) latex_documents = [ ("index", "{0}.tex".format(project), "{0} Documentation".format(project), "Pinax", "manual"), ] man_pages = [ ("index", project, "{0} Documentation".format(project), ["Pinax"], 1) ] sys.path.insert(0, os.pardir) m = __import__("account") version = m.__version__ release = version
from __future__ import unicode_literals import os import sys extensions = [] templates_path = [] source_suffix = ".rst" master_doc = "index" project = "django-user-accounts" copyright_holder = "James Tauber and contributors" copyright = "2014, {0}",format(copyright_holder) exclude_patterns = ["_build"] pygments_style = "sphinx" html_theme = "default" htmlhelp_basename = "{0}doc".format(project) latex_documents = [ ("index", "{0}.tex".format(project), "{0} Documentation".format(project), "Pinax", "manual"), ] man_pages = [ ("index", project, "{0} Documentation".format(project), ["Pinax"], 1) ] sys.path.insert(0, os.pardir) m = __import__("account") version = m.__version__ release = version
Increment the year in the copyright
Increment the year in the copyright
Python
mit
jmburbach/django-user-accounts,mysociety/django-user-accounts,jpotterm/django-user-accounts,mgpyh/django-user-accounts,GeoNode/geonode-user-accounts,mentholi/django-user-accounts,ntucker/django-user-accounts,pinax/django-user-accounts,osmfj/django-user-accounts,pinax/django-user-accounts,jawed123/django-user-accounts,jacobwegner/django-user-accounts,mentholi/django-user-accounts,jawed123/django-user-accounts,ntucker/django-user-accounts,rizumu/django-user-accounts,rizumu/django-user-accounts,mysociety/django-user-accounts,jmburbach/django-user-accounts,jpotterm/django-user-accounts,nderituedwin/django-user-accounts,osmfj/django-user-accounts,jacobwegner/django-user-accounts,nderituedwin/django-user-accounts,GeoNode/geonode-user-accounts
--- +++ @@ -10,7 +10,7 @@ master_doc = "index" project = "django-user-accounts" copyright_holder = "James Tauber and contributors" -copyright = "2013, {0}",format(copyright_holder) +copyright = "2014, {0}",format(copyright_holder) exclude_patterns = ["_build"] pygments_style = "sphinx" html_theme = "default"
fd76a19b399bb52dc2cd69fda9bbfed912c8a407
docs/conf.py
docs/conf.py
# -*- coding: utf-8 -*- import sys import os from glob import glob # ------------------------------------------------------------------------- # Configure extensions extensions = [ 'sphinx.ext.autodoc', ] # ------------------------------------------------------------------------- # General configuration project = u'sphinxcontrib.traceables' copyright = u'2015, Christo' version = '0.1' # The short X.Y version. release = '0.1' # The full version, incl alpha/beta/rc. templates_path = ['_templates'] source_suffix = '.txt' # The suffix of source filenames. master_doc = 'index' # The master toctree document. today_fmt = '%Y-%m-%d' exclude_patterns = ['_build'] pygments_style = 'sphinx' keep_warnings = True # Keep warnings in output documents. # ------------------------------------------------------------------------- # Configure HTML output html_theme = 'sphinx_rtd_theme' html_show_sourcelink = True # Link to source from pages.
# -*- coding: utf-8 -*- import sys import os from glob import glob # ------------------------------------------------------------------------- # Configure extensions extensions = [ 'sphinx.ext.autodoc', ] # ------------------------------------------------------------------------- # Helper function for retrieving info from files def read(*names): root_dir = os.path.dirname(__file__) path = os.path.join(root_dir, *names) with open(path) as f: return f.read() # ------------------------------------------------------------------------- # General configuration project = u'sphinxcontrib.traceables' copyright = u'2015, Christo' release = read('..', 'VERSION.txt') # The full version, incl alpha/beta/rc. version = '.'.join(release.split('.')[0:2]) # The short X.Y version. templates_path = ['_templates'] source_suffix = '.txt' # The suffix of source filenames. master_doc = 'index' # The master toctree document. today_fmt = '%Y-%m-%d' exclude_patterns = ['_build'] pygments_style = 'sphinx' keep_warnings = True # Keep warnings in output documents. # ------------------------------------------------------------------------- # Configure HTML output html_theme = 'sphinx_rtd_theme' html_show_sourcelink = True # Link to source from pages.
Add retrieval of docs version from VERSION.txt
Add retrieval of docs version from VERSION.txt
Python
apache-2.0
t4ngo/sphinxcontrib-traceables
--- +++ @@ -12,12 +12,21 @@ ] # ------------------------------------------------------------------------- +# Helper function for retrieving info from files + +def read(*names): + root_dir = os.path.dirname(__file__) + path = os.path.join(root_dir, *names) + with open(path) as f: + return f.read() + +# ------------------------------------------------------------------------- # General configuration project = u'sphinxcontrib.traceables' copyright = u'2015, Christo' -version = '0.1' # The short X.Y version. -release = '0.1' # The full version, incl alpha/beta/rc. +release = read('..', 'VERSION.txt') # The full version, incl alpha/beta/rc. +version = '.'.join(release.split('.')[0:2]) # The short X.Y version. templates_path = ['_templates'] source_suffix = '.txt' # The suffix of source filenames.
d7c5001f2109b7e97fbb5f8f82282f8187683365
docs/conf.py
docs/conf.py
import os import sdv project = u'stix-validator' copyright = u'2015, The MITRE Corporation' version = sdv.__version__ release = version extensions = [ 'sphinx.ext.autodoc', 'sphinxcontrib.napoleon', ] templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' rst_prolog = """ **Version**: {} """.format(release) exclude_patterns = ['_build'] pygments_style = 'sphinx' on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] else: html_theme = 'default' latex_elements = {} latex_documents = [ ('index', 'stix-validator.tex', u'stix-validator Documentation', u'The MITRE Corporation', 'manual'), ]
import os import sdv project = u'stix-validator' copyright = u'2015, The MITRE Corporation' version = sdv.__version__ release = version extensions = [ 'sphinx.ext.autodoc', 'sphinxcontrib.napoleon', ] templates_path = ['_templates'] source_suffix = '.rst' master_doc = 'index' rst_prolog = """ **Version**: {0} """.format(release) exclude_patterns = ['_build'] pygments_style = 'sphinx' on_rtd = os.environ.get('READTHEDOCS', None) == 'True' if not on_rtd: # only import and set the theme if we're building docs locally import sphinx_rtd_theme html_theme = 'sphinx_rtd_theme' html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] else: html_theme = 'default' latex_elements = {} latex_documents = [ ('index', 'stix-validator.tex', u'stix-validator Documentation', u'The MITRE Corporation', 'manual'), ]
Fix zero-length field error when building docs in Python 2.6
Fix zero-length field error when building docs in Python 2.6
Python
bsd-3-clause
pombredanne/stix-validator,STIXProject/stix-validator
--- +++ @@ -17,7 +17,7 @@ master_doc = 'index' rst_prolog = """ -**Version**: {} +**Version**: {0} """.format(release) exclude_patterns = ['_build']
889473ba81816aa0ad349823515843c337a6b985
benchexec/tools/deagle.py
benchexec/tools/deagle.py
# This file is part of BenchExec, a framework for reliable benchmarking: # https://github.com/sosy-lab/benchexec # # SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> # # SPDX-License-Identifier: Apache-2.0 import benchexec.result as result import benchexec.util as util import benchexec.tools.template class Tool(benchexec.tools.template.BaseTool): def executable(self): return util.find_executable("deagle") def name(self): return "Deagle" def version(self, executable): return self._version_from_tool(executable) def cmdline(self, executable, options, tasks, propertyfile, rlimits): options = options + ["--32", "--no-unwinding-assertions", "--closure"] return [executable] + options + tasks def determine_result(self, returncode, returnsignal, output, isTimeout): status = result.RESULT_UNKNOWN stroutput = str(output) if isTimeout: status = "TIMEOUT" elif "SUCCESSFUL" in stroutput: status = result.RESULT_TRUE_PROP elif "FAILED" in stroutput: status = result.RESULT_FALSE_REACH elif "UNKNOWN" in stroutput: status = result.RESULT_UNKNOWN else: status = result.RESULT_UNKNOWN return status
# This file is part of BenchExec, a framework for reliable benchmarking: # https://github.com/sosy-lab/benchexec # # SPDX-FileCopyrightText: 2007-2020 Dirk Beyer <https://www.sosy-lab.org> # # SPDX-License-Identifier: Apache-2.0 import benchexec.result as result import benchexec.util as util import benchexec.tools.template class Tool(benchexec.tools.template.BaseTool2): def executable(self, tool_locator): return tool_locator.find_executable("deagle") def name(self): return "Deagle" def version(self, executable): return self._version_from_tool(executable) def get_data_model(self, task): if isinstance(task.options, dict) and task.options.get("language") == "C": data_model = task.options.get("data_model") if data_model == "LP64": return ["--64"] return ["--32"] # default def cmdline(self, executable, options, task, rlimits): return [executable] + options + self.get_data_model(task) + list(task.input_files_or_identifier) def determine_result(self, run): status = result.RESULT_UNKNOWN output = run.output stroutput = str(output) if "SUCCESSFUL" in stroutput: status = result.RESULT_TRUE_PROP elif "FAILED" in stroutput: status = result.RESULT_FALSE_REACH else: status = result.RESULT_UNKNOWN return status
Move --closure and --no-unwinding-assertions to bench-defs; rewrite choices between --32 and --64
Move --closure and --no-unwinding-assertions to bench-defs; rewrite choices between --32 and --64
Python
apache-2.0
ultimate-pa/benchexec,sosy-lab/benchexec,sosy-lab/benchexec,ultimate-pa/benchexec,ultimate-pa/benchexec,ultimate-pa/benchexec,ultimate-pa/benchexec,sosy-lab/benchexec,ultimate-pa/benchexec,sosy-lab/benchexec,sosy-lab/benchexec,sosy-lab/benchexec
--- +++ @@ -10,9 +10,9 @@ import benchexec.tools.template -class Tool(benchexec.tools.template.BaseTool): - def executable(self): - return util.find_executable("deagle") +class Tool(benchexec.tools.template.BaseTool2): + def executable(self, tool_locator): + return tool_locator.find_executable("deagle") def name(self): return "Deagle" @@ -20,23 +20,26 @@ def version(self, executable): return self._version_from_tool(executable) - def cmdline(self, executable, options, tasks, propertyfile, rlimits): - options = options + ["--32", "--no-unwinding-assertions", "--closure"] - return [executable] + options + tasks + def get_data_model(self, task): + if isinstance(task.options, dict) and task.options.get("language") == "C": + data_model = task.options.get("data_model") + if data_model == "LP64": + return ["--64"] + return ["--32"] # default - def determine_result(self, returncode, returnsignal, output, isTimeout): + def cmdline(self, executable, options, task, rlimits): + return [executable] + options + self.get_data_model(task) + list(task.input_files_or_identifier) + def determine_result(self, run): status = result.RESULT_UNKNOWN + + output = run.output stroutput = str(output) - if isTimeout: - status = "TIMEOUT" - elif "SUCCESSFUL" in stroutput: + if "SUCCESSFUL" in stroutput: status = result.RESULT_TRUE_PROP elif "FAILED" in stroutput: status = result.RESULT_FALSE_REACH - elif "UNKNOWN" in stroutput: - status = result.RESULT_UNKNOWN else: status = result.RESULT_UNKNOWN
6bc1f6e466fa09dd0bc6a076f9081e1aa03efdc7
examples/translations/dutch_test_1.py
examples/translations/dutch_test_1.py
# Dutch Language Test from seleniumbase.translate.dutch import Testgeval class MijnTestklasse(Testgeval): def test_voorbeeld_1(self): self.openen("https://nl.wikipedia.org/wiki/Hoofdpagina") self.controleren_element('a[title*="hoofdpagina gaan"]') self.controleren_tekst("Welkom op Wikipedia", "td.hp-welkom") self.typ("#searchInput", "Stroopwafel") self.klik("#searchButton") self.controleren_tekst("Stroopwafel", "#firstHeading") self.controleren_element('img[alt="Stroopwafels"]') self.typ("#searchInput", "Rijksmuseum Amsterdam") self.klik("#searchButton") self.controleren_tekst("Rijksmuseum", "#firstHeading") self.controleren_element('img[alt="Het Rijksmuseum"]') self.terug() self.controleren_ware("Stroopwafel" in self.huidige_url_ophalen()) self.vooruit() self.controleren_ware("Rijksmuseum" in self.huidige_url_ophalen())
# Dutch Language Test from seleniumbase.translate.dutch import Testgeval class MijnTestklasse(Testgeval): def test_voorbeeld_1(self): self.openen("https://nl.wikipedia.org/wiki/Hoofdpagina") self.controleren_element('a[title*="hoofdpagina gaan"]') self.controleren_tekst("Welkom op Wikipedia", "td.hp-welkom") self.typ("#searchInput", "Stroopwafel") self.klik("#searchButton") self.controleren_tekst("Stroopwafel", "#firstHeading") self.controleren_element('img[src*="Stroopwafels"]') self.typ("#searchInput", "Rijksmuseum Amsterdam") self.klik("#searchButton") self.controleren_tekst("Rijksmuseum", "#firstHeading") self.controleren_element('img[src*="Rijksmuseum"]') self.terug() self.controleren_ware("Stroopwafel" in self.huidige_url_ophalen()) self.vooruit() self.controleren_ware("Rijksmuseum" in self.huidige_url_ophalen())
Update the Dutch example test
Update the Dutch example test
Python
mit
seleniumbase/SeleniumBase,seleniumbase/SeleniumBase,mdmintz/SeleniumBase,mdmintz/SeleniumBase,mdmintz/SeleniumBase,seleniumbase/SeleniumBase,seleniumbase/SeleniumBase,mdmintz/SeleniumBase
--- +++ @@ -11,11 +11,11 @@ self.typ("#searchInput", "Stroopwafel") self.klik("#searchButton") self.controleren_tekst("Stroopwafel", "#firstHeading") - self.controleren_element('img[alt="Stroopwafels"]') + self.controleren_element('img[src*="Stroopwafels"]') self.typ("#searchInput", "Rijksmuseum Amsterdam") self.klik("#searchButton") self.controleren_tekst("Rijksmuseum", "#firstHeading") - self.controleren_element('img[alt="Het Rijksmuseum"]') + self.controleren_element('img[src*="Rijksmuseum"]') self.terug() self.controleren_ware("Stroopwafel" in self.huidige_url_ophalen()) self.vooruit()
f8d8aac9f342c10268165f4e2e641a6c667f97fd
Algorithms/Implementation/the-grid-search.py
Algorithms/Implementation/the-grid-search.py
# Python 2 import sys def search_inside(G, P, R, C, r, c): for i in range(R - r + 1): for j in range(C - c + 1): valid = True for k in range(r): if G[i + k][j:j + c] != P[k]: valid = False break if valid: print 'YES' return print 'NO' t = int(raw_input()) for i in range(t): R,C = [int(j) for j in raw_input().split()] G = [] for g in range(R): G_m = str(raw_input().strip()) G.append(G_m) r,c = [int(k) for k in raw_input().split()] P = [] for p in range(r): P_n = str(raw_input().strip()) P.append(P_n) search_inside(G, P, R, C, r, c)
# Python 2 import sys def search_inside(G, P, R, C, r, c): for i in range(R - r + 1): for j in range(C - c + 1): valid = True for k in range(r): if G[i + k][j:j + c] != P[k]: valid = False break # break out of for-loop and go to next value of j if valid: print 'YES' return print 'NO' t = int(raw_input()) for i in range(t): R,C = [int(j) for j in raw_input().split()] G = [] for g in range(R): G_m = str(raw_input().strip()) G.append(G_m) r,c = [int(k) for k in raw_input().split()] P = [] for p in range(r): P_n = str(raw_input().strip()) P.append(P_n) search_inside(G, P, R, C, r, c)
Add comment to clarify roll of break on line 12
Add comment to clarify roll of break on line 12
Python
mit
ugaliguy/HackerRank,ugaliguy/HackerRank,ugaliguy/HackerRank
--- +++ @@ -9,7 +9,7 @@ for k in range(r): if G[i + k][j:j + c] != P[k]: valid = False - break + break # break out of for-loop and go to next value of j if valid: print 'YES'
7e068075c6cd231926cc5f5469472f3fafba7c18
biwako/bin/fields/util.py
biwako/bin/fields/util.py
import sys from .base import Field class Reserved(Field): def __init__(self, *args, **kwargs): super(Reserved, self).__init__(*args, **kwargs) # Hack to add the reserved field to the class without # having to explicitly give it a (likely useless) name frame = sys._getframe(2) locals = frame.f_locals locals[self.get_available_name(locals.keys())] = self def get_available_name(self, locals): i = 0 while True: name = '_reserved_%s' % i if name not in locals: return name i += 1 def set_name(self, name): if hasattr(self, 'name'): raise TypeError('Reserved fields must not be given an attribute name') super(Reserved, self).set_name(name) def encode(self, value): return b'\x00' * self.size def decode(self, value): return None
import sys from .base import Field from ..fields import args class Reserved(Field): default = args.Override(default=None) def __init__(self, *args, **kwargs): super(Reserved, self).__init__(*args, **kwargs) # Hack to add the reserved field to the class without # having to explicitly give it a (likely useless) name frame = sys._getframe(2) locals = frame.f_locals locals[self.get_available_name(locals.keys())] = self def get_available_name(self, locals): i = 0 while True: name = '_reserved_%s' % i if name not in locals: return name i += 1 def set_name(self, name): if hasattr(self, 'name'): raise TypeError('Reserved fields must not be given an attribute name') super(Reserved, self).set_name(name) def encode(self, value): return b'\x00' * self.size def decode(self, value): return None
Add a default value of None for reserved fields
Add a default value of None for reserved fields
Python
bsd-3-clause
gulopine/steel
--- +++ @@ -1,9 +1,12 @@ import sys from .base import Field +from ..fields import args class Reserved(Field): + default = args.Override(default=None) + def __init__(self, *args, **kwargs): super(Reserved, self).__init__(*args, **kwargs)
dc2c960bb937cc287dedf95d407ed2e95f3f6724
sigma_files/serializers.py
sigma_files/serializers.py
from rest_framework import serializers from sigma.utils import CurrentUserCreateOnlyDefault from sigma_files.models import Image class ImageSerializer(serializers.ModelSerializer): class Meta: model = Image file = serializers.ImageField(max_length=255) height = serializers.IntegerField(source='file.height', read_only=True) width = serializers.IntegerField(source='file.width', read_only=True) owner = serializers.PrimaryKeyRelatedField(read_only=True, default=CurrentUserCreateOnlyDefault())
from rest_framework import serializers from dry_rest_permissions.generics import DRYPermissionsField from sigma.utils import CurrentUserCreateOnlyDefault from sigma_files.models import Image class ImageSerializer(serializers.ModelSerializer): class Meta: model = Image file = serializers.ImageField(max_length=255) height = serializers.IntegerField(source='file.height', read_only=True) width = serializers.IntegerField(source='file.width', read_only=True) owner = serializers.PrimaryKeyRelatedField(read_only=True, default=CurrentUserCreateOnlyDefault()) permissions = DRYPermissionsField(actions=['read', 'write'])
Add permissions field on ImageSerializer
Add permissions field on ImageSerializer
Python
agpl-3.0
ProjetSigma/backend,ProjetSigma/backend
--- +++ @@ -1,4 +1,5 @@ from rest_framework import serializers +from dry_rest_permissions.generics import DRYPermissionsField from sigma.utils import CurrentUserCreateOnlyDefault from sigma_files.models import Image @@ -12,3 +13,4 @@ height = serializers.IntegerField(source='file.height', read_only=True) width = serializers.IntegerField(source='file.width', read_only=True) owner = serializers.PrimaryKeyRelatedField(read_only=True, default=CurrentUserCreateOnlyDefault()) + permissions = DRYPermissionsField(actions=['read', 'write'])
d9262650eb1ce108c196bc10b0edcd8de6429dc2
fabconfig.py
fabconfig.py
from fabric.api import env env.client = 'zsoobhan' env.project_code = 'prometheus' env.web_dir = 'www' # Environment-agnostic folders env.project_dir = '/var/www/%(client)s/%(project_code)s' % env env.static_dir = '/mnt/static/%(client)s/%(project_code)s' % env env.builds_dir = '%(project_dir)s/builds' % env def _configure(build_name): env.build = build_name env.virtualenv = '%(project_dir)s/virtualenvs/%(build)s/' % env env.data_dir = '%(project_dir)s/data/%(build)s/' % env env.nginx_conf = 'www/deploy/nginx/%(build)s.conf' % env env.supervisord_conf = 'www/deploy/supervisord/%(build)s.conf' % env env.wsgi = 'deploy/wsgi/%(build)s.wsgi' % env env.webserver_user = 'www-data' def prod(): _configure('prod') env.hosts = ['ec2-54-77-186-157.eu-west-1.compute.amazonaws.com'] env.remote_user = 'ubuntu' def test(): _configure('test') env.remote_user = 'ubuntu'
from fabric.api import env env.client = 'zsoobhan' env.project_code = 'prometheus' env.web_dir = 'www' # Environment-agnostic folders env.project_dir = '/var/www/%(client)s/%(project_code)s' % env env.static_dir = '/mnt/static/%(client)s/%(project_code)s' % env env.builds_dir = '%(project_dir)s/builds' % env def _configure(build_name): env.build = build_name env.virtualenv = '%(project_dir)s/virtualenvs/%(build)s/' % env env.data_dir = '%(project_dir)s/data/%(build)s/' % env env.nginx_conf = 'www/deploy/nginx/%(build)s.conf' % env env.supervisord_conf = 'www/deploy/supervisord/%(build)s.conf' % env env.wsgi = 'deploy/wsgi/%(build)s.wsgi' % env env.webserver_user = 'www-data' def prod(): _configure('prod') env.hosts = ['ec2-54-154-143-128.eu-west-1.compute.amazonaws.com'] env.remote_user = 'ubuntu' def test(): _configure('test') env.remote_user = 'ubuntu'
Switch to new ec2 instance
Switch to new ec2 instance
Python
mit
zsoobhan/prometheus,zsoobhan/prometheus,zsoobhan/prometheus,zsoobhan/prometheus
--- +++ @@ -23,7 +23,7 @@ def prod(): _configure('prod') - env.hosts = ['ec2-54-77-186-157.eu-west-1.compute.amazonaws.com'] + env.hosts = ['ec2-54-154-143-128.eu-west-1.compute.amazonaws.com'] env.remote_user = 'ubuntu'
05c9039c364d87c890cffdb9de7f0c8d1f7f9cb3
tfx/orchestration/config/kubernetes_component_config.py
tfx/orchestration/config/kubernetes_component_config.py
# Lint as: python2, python3 # Copyright 2019 Google LLC. All Rights Reserved. # # 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. """Component config for Kubernets Pod execution.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from typing import Any, Dict, Text, Union from kubernetes import client from tfx.orchestration.config import base_component_config class KubernetesComponentConfig(base_component_config.BaseComponentConfig): """Component config which holds Kubernetes Pod execution args. Attributes: pod: the spec for a Pod. It can either be an instance of client.V1Pod or a dict of a Pod spec. The spec details are: https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Pod.md """ def __init__(self, pod: Union[client.V1Pod, Dict[Text, Any]]): if not pod: raise ValueError('pod must have a value.') self.pod = pod
# Lint as: python2, python3 # Copyright 2019 Google LLC. All Rights Reserved. # # 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. """Component config for Kubernets Pod execution.""" from __future__ import absolute_import from __future__ import division from __future__ import print_function from typing import Any, Dict, Text, Union from kubernetes import client from tfx.orchestration.config import base_component_config from tfx.orchestration.launcher import container_common class KubernetesComponentConfig(base_component_config.BaseComponentConfig): """Component config which holds Kubernetes Pod execution args. Attributes: pod: the spec for a Pod. It can either be an instance of client.V1Pod or a dict of a Pod spec. The spec details are: https://github.com/kubernetes-client/python/blob/master/kubernetes/docs/V1Pod.md """ def __init__(self, pod: Union[client.V1Pod, Dict[Text, Any]]): if not pod: raise ValueError('pod must have a value.') self.pod = container_common.to_swagger_dict(pod)
Convert k8s pod spec into dict structure to make sure that it's json serializable.
Convert k8s pod spec into dict structure to make sure that it's json serializable. PiperOrigin-RevId: 279162159
Python
apache-2.0
tensorflow/tfx,tensorflow/tfx
--- +++ @@ -23,6 +23,7 @@ from kubernetes import client from tfx.orchestration.config import base_component_config +from tfx.orchestration.launcher import container_common class KubernetesComponentConfig(base_component_config.BaseComponentConfig): @@ -37,4 +38,4 @@ def __init__(self, pod: Union[client.V1Pod, Dict[Text, Any]]): if not pod: raise ValueError('pod must have a value.') - self.pod = pod + self.pod = container_common.to_swagger_dict(pod)
0f0a5e42422f71143c8bcbc3278ad0dc3b81c818
eratosthenes_lambda.py
eratosthenes_lambda.py
from __future__ import print_function from timeit import default_timer as timer import json import datetime print('Loading function') def eratosthenes(n): sieve = [ True for i in range(n+1) ] def markOff(pv): for i in range(pv+pv, n+1, pv): sieve[i] = False markOff(2) for i in range(3, n+1): if sieve[i]: markOff(i) return [ i for i in range(1, n+1) if sieve[i] ] def lambda_handler(event, context): start = timer() #print("Received event: " + json.dumps(event, indent=2)) maxPrime = int(event['queryStringParameters']['max']) numLoops = int(event['queryStringParameters']['loops']) print("looping " + str(numLoops) + " time(s)") for loop in range (0, numLoops): primes = eratosthenes(maxPrime) print("Highest 3 primes: " + str(primes.pop()) + ", " + str(primes.pop()) + ", " + str(primes.pop())) durationSeconds = timer() - start return {"statusCode": 200, \ "headers": {"Content-Type": "application/json"}, \ "body": "{\"durationSeconds\": " + str(durationSeconds) + \ ", \"max\": " + str(maxPrime) + ", \"loops\": " + str(numLoops) + "}"}
from __future__ import print_function from timeit import default_timer as timer import json import datetime print('Loading function') def eratosthenes(n): sieve = [ True for i in range(n+1) ] def markOff(pv): for i in range(pv+pv, n+1, pv): sieve[i] = False markOff(2) for i in range(3, n+1): if sieve[i]: markOff(i) return [ i for i in range(1, n+1) if sieve[i] ] def lambda_handler(event, context): start = timer() #print("Received event: " + json.dumps(event, indent=2)) maxPrime = int(event['queryStringParameters']['max']) numLoops = int(event['queryStringParameters']['loops']) print("looping " + str(numLoops) + " time(s)") for loop in range (0, numLoops): primes = eratosthenes(maxPrime) print("Highest 3 primes: " + str(primes.pop()) + ", " + str(primes.pop()) + ", " + str(primes.pop())) durationSeconds = timer() - start return {"statusCode": 200, \ "headers": {"Content-Type": "application/json"}, \ "body": "{\"durationSeconds\": " + str(durationSeconds) + \ ", \"max\": " + str(maxPrime) + ", \"loops\": " + str(numLoops) + "}"}
Convert tabs to spaces per PEP 8.
Convert tabs to spaces per PEP 8.
Python
mit
jconning/lambda-cpu-cost,jconning/lambda-cpu-cost
--- +++ @@ -10,8 +10,8 @@ def eratosthenes(n): sieve = [ True for i in range(n+1) ] def markOff(pv): - for i in range(pv+pv, n+1, pv): - sieve[i] = False + for i in range(pv+pv, n+1, pv): + sieve[i] = False markOff(2) for i in range(3, n+1): if sieve[i]: @@ -28,11 +28,11 @@ print("looping " + str(numLoops) + " time(s)") for loop in range (0, numLoops): primes = eratosthenes(maxPrime) - print("Highest 3 primes: " + str(primes.pop()) + ", " + str(primes.pop()) + ", " + str(primes.pop())) + print("Highest 3 primes: " + str(primes.pop()) + ", " + str(primes.pop()) + ", " + str(primes.pop())) durationSeconds = timer() - start return {"statusCode": 200, \ - "headers": {"Content-Type": "application/json"}, \ - "body": "{\"durationSeconds\": " + str(durationSeconds) + \ - ", \"max\": " + str(maxPrime) + ", \"loops\": " + str(numLoops) + "}"} + "headers": {"Content-Type": "application/json"}, \ + "body": "{\"durationSeconds\": " + str(durationSeconds) + \ + ", \"max\": " + str(maxPrime) + ", \"loops\": " + str(numLoops) + "}"}
525e7d5061326c7c815f4ede7757afb7c085ff78
apartments/models.py
apartments/models.py
from sqlalchemy import create_engine, Column, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker Base = declarative_base() class Listing(Base): __tablename__ = 'listings' id = Column(Integer, primary_key=True) craigslist_id = Column(String, unique=True) url = Column(String, unique=True) engine = create_engine('sqlite:///apartments.db') Base.metadata.create_all(engine) Session = sessionmaker(bind=engine) session = Session()
from sqlalchemy import create_engine, Column, DateTime, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker from sqlalchemy.sql import func Base = declarative_base() class Listing(Base): __tablename__ = 'listings' id = Column(Integer, primary_key=True) timestamp = Column(DateTime, server_default=func.now()) craigslist_id = Column(String, unique=True) url = Column(String, unique=True) engine = create_engine('sqlite:///apartments.db') Base.metadata.create_all(engine) Session = sessionmaker(bind=engine) session = Session()
Add timestamp field to Listing
Add timestamp field to Listing
Python
mit
rlucioni/apartments,rlucioni/craigbot,rlucioni/craigbot
--- +++ @@ -1,6 +1,7 @@ -from sqlalchemy import create_engine, Column, Integer, String +from sqlalchemy import create_engine, Column, DateTime, Integer, String from sqlalchemy.ext.declarative import declarative_base from sqlalchemy.orm import sessionmaker +from sqlalchemy.sql import func Base = declarative_base() @@ -10,6 +11,7 @@ __tablename__ = 'listings' id = Column(Integer, primary_key=True) + timestamp = Column(DateTime, server_default=func.now()) craigslist_id = Column(String, unique=True) url = Column(String, unique=True)
f67746750bdd2a1d6e662b1fc36d5a6fa13098c5
scripts/generate.py
scripts/generate.py
#!/usr/bin/env python template = """#!/bin/bash #PBS -l walltime=72:00:00 #PBS -l nodes=1:ppn=1 cd /RQusagers/vanmerb/rnnencdec export PYTHONPATH=/RQusagers/vanmerb/rnnencdec/groundhog-private/:$PYTHONPATH python /RQusagers/vanmerb/rnnencdec/groundhog-private/scripts/RNN_Enc_Dec_Phrase.py \"{options}\" >{log} 2>&1""" params = [ ("dict(dim=250, dim_mlp=250)", "run1"), ("dict(dim=500, dim_mlp=500)", "run2"), ("dict(rank_n_approx=200)", "run3"), ("dict(rank_n_approx=500)", "run4"), ("dict(avg_word=False)", "run5") ] for options, name in params: with open("{}.sh".format(name), "w") as script: log = "{}.log".format(name) print >>script, template.format(**locals())
#!/usr/bin/env python template = """#!/bin/bash #PBS -l walltime=72:00:00 #PBS -l nodes=1:ppn=1 cd /RQusagers/vanmerb/rnnencdec export PYTHONPATH=/RQusagers/vanmerb/rnnencdec/groundhog-private/:$PYTHONPATH python /RQusagers/vanmerb/rnnencdec/groundhog-private/scripts/RNN_Enc_Dec_Phrase.py \"{options}\" >{log} 2>&1""" params = [ ("dict(dim=250, dim_mlp=250, prefix='model_run1_')", "run1"), ("dict(dim=500, dim_mlp=500, prefix='model_run2_')", "run2"), ("dict(rank_n_approx=200, prefix='model_run3_')", "run3"), ("dict(rank_n_approx=500, prefix='model_run4_')", "run4"), ("dict(avg_word=False, prefix='model_run5_')", "run5") ] for options, name in params: with open("{}.sh".format(name), "w") as script: log = "{}.log".format(name) print >>script, template.format(**locals())
Add different prefixes for the experiments
Add different prefixes for the experiments
Python
bsd-3-clause
rizar/groundhog-private
--- +++ @@ -11,11 +11,11 @@ python /RQusagers/vanmerb/rnnencdec/groundhog-private/scripts/RNN_Enc_Dec_Phrase.py \"{options}\" >{log} 2>&1""" params = [ - ("dict(dim=250, dim_mlp=250)", "run1"), - ("dict(dim=500, dim_mlp=500)", "run2"), - ("dict(rank_n_approx=200)", "run3"), - ("dict(rank_n_approx=500)", "run4"), - ("dict(avg_word=False)", "run5") + ("dict(dim=250, dim_mlp=250, prefix='model_run1_')", "run1"), + ("dict(dim=500, dim_mlp=500, prefix='model_run2_')", "run2"), + ("dict(rank_n_approx=200, prefix='model_run3_')", "run3"), + ("dict(rank_n_approx=500, prefix='model_run4_')", "run4"), + ("dict(avg_word=False, prefix='model_run5_')", "run5") ] for options, name in params:
7675547ab7669d1df03bf258ffc676799879a191
build/android/pylib/gtest/gtest_config.py
build/android/pylib/gtest/gtest_config.py
# Copyright (c) 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. """Configuration file for android gtest suites.""" # Add new suites here before upgrading them to the stable list below. EXPERIMENTAL_TEST_SUITES = [ 'content_browsertests', ] # Do not modify this list without approval of an android owner. # This list determines which suites are run by default, both for local # testing and on android trybots running on commit-queue. STABLE_TEST_SUITES = [ 'android_webview_unittests', 'base_unittests', 'cc_unittests', 'components_unittests', 'content_unittests', 'gpu_unittests', 'ipc_tests', 'media_unittests', 'net_unittests', 'sql_unittests', 'sync_unit_tests', 'ui_unittests', 'unit_tests', 'webkit_compositor_bindings_unittests', 'webkit_unit_tests', 'breakpad_unittests', 'sandbox_linux_unittests', ]
# Copyright (c) 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. """Configuration file for android gtest suites.""" # Add new suites here before upgrading them to the stable list below. EXPERIMENTAL_TEST_SUITES = [ ] # Do not modify this list without approval of an android owner. # This list determines which suites are run by default, both for local # testing and on android trybots running on commit-queue. STABLE_TEST_SUITES = [ 'android_webview_unittests', 'base_unittests', 'cc_unittests', 'components_unittests', 'content_unittests', 'gpu_unittests', 'ipc_tests', 'media_unittests', 'net_unittests', 'sql_unittests', 'sync_unit_tests', 'ui_unittests', 'unit_tests', 'webkit_compositor_bindings_unittests', 'webkit_unit_tests', 'breakpad_unittests', 'sandbox_linux_unittests', 'content_browsertests', ]
Move content_browsertests to main waterfall/trybots.
[Android] Move content_browsertests to main waterfall/trybots. It's passing consistently on android_fyi_dbg trybots and on FYI waterfall bots running ICS. BUG=270144 NOTRY=True Review URL: https://chromiumcodereview.appspot.com/22299007 git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@216442 0039d316-1c4b-4281-b951-d872f2087c98
Python
bsd-3-clause
jaruba/chromium.src,krieger-od/nwjs_chromium.src,krieger-od/nwjs_chromium.src,Chilledheart/chromium,patrickm/chromium.src,hgl888/chromium-crosswalk,M4sse/chromium.src,Chilledheart/chromium,Fireblend/chromium-crosswalk,bright-sparks/chromium-spacewalk,markYoungH/chromium.src,ltilve/chromium,ChromiumWebApps/chromium,markYoungH/chromium.src,ChromiumWebApps/chromium,hgl888/chromium-crosswalk,M4sse/chromium.src,Chilledheart/chromium,fujunwei/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,fujunwei/chromium-crosswalk,littlstar/chromium.src,Jonekee/chromium.src,dushu1203/chromium.src,jaruba/chromium.src,chuan9/chromium-crosswalk,bright-sparks/chromium-spacewalk,markYoungH/chromium.src,bright-sparks/chromium-spacewalk,mogoweb/chromium-crosswalk,dushu1203/chromium.src,dushu1203/chromium.src,hgl888/chromium-crosswalk,chuan9/chromium-crosswalk,jaruba/chromium.src,TheTypoMaster/chromium-crosswalk,Pluto-tv/chromium-crosswalk,Jonekee/chromium.src,anirudhSK/chromium,krieger-od/nwjs_chromium.src,markYoungH/chromium.src,mogoweb/chromium-crosswalk,M4sse/chromium.src,Jonekee/chromium.src,ondra-novak/chromium.src,jaruba/chromium.src,M4sse/chromium.src,hgl888/chromium-crosswalk-efl,anirudhSK/chromium,hgl888/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,hgl888/chromium-crosswalk-efl,ChromiumWebApps/chromium,Pluto-tv/chromium-crosswalk,dushu1203/chromium.src,dushu1203/chromium.src,M4sse/chromium.src,hgl888/chromium-crosswalk-efl,mogoweb/chromium-crosswalk,krieger-od/nwjs_chromium.src,mogoweb/chromium-crosswalk,Fireblend/chromium-crosswalk,anirudhSK/chromium,M4sse/chromium.src,PeterWangIntel/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,M4sse/chromium.src,Fireblend/chromium-crosswalk,axinging/chromium-crosswalk,jaruba/chromium.src,krieger-od/nwjs_chromium.src,crosswalk-project/chromium-crosswalk-efl,M4sse/chromium.src,Fireblend/chromium-crosswalk,axinging/chromium-crosswalk,mogoweb/chromium-crosswalk,bright-sparks/chromium-spacewalk,ltilve/chromium,anirudhSK/chromium,littlstar/chromium.src,dushu1203/chromium.src,krieger-od/nwjs_chromium.src,mohamed--abdel-maksoud/chromium.src,littlstar/chromium.src,jaruba/chromium.src,hgl888/chromium-crosswalk-efl,patrickm/chromium.src,Chilledheart/chromium,axinging/chromium-crosswalk,mogoweb/chromium-crosswalk,ltilve/chromium,ChromiumWebApps/chromium,TheTypoMaster/chromium-crosswalk,ondra-novak/chromium.src,crosswalk-project/chromium-crosswalk-efl,Just-D/chromium-1,hgl888/chromium-crosswalk,Fireblend/chromium-crosswalk,dednal/chromium.src,ChromiumWebApps/chromium,axinging/chromium-crosswalk,jaruba/chromium.src,Pluto-tv/chromium-crosswalk,fujunwei/chromium-crosswalk,ChromiumWebApps/chromium,ltilve/chromium,Just-D/chromium-1,dednal/chromium.src,hgl888/chromium-crosswalk-efl,ltilve/chromium,M4sse/chromium.src,Jonekee/chromium.src,fujunwei/chromium-crosswalk,patrickm/chromium.src,anirudhSK/chromium,Fireblend/chromium-crosswalk,Jonekee/chromium.src,anirudhSK/chromium,chuan9/chromium-crosswalk,chuan9/chromium-crosswalk,littlstar/chromium.src,fujunwei/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,Jonekee/chromium.src,Chilledheart/chromium,crosswalk-project/chromium-crosswalk-efl,ondra-novak/chromium.src,Pluto-tv/chromium-crosswalk,Chilledheart/chromium,fujunwei/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,mohamed--abdel-maksoud/chromium.src,Jonekee/chromium.src,ondra-novak/chromium.src,M4sse/chromium.src,anirudhSK/chromium,Chilledheart/chromium,littlstar/chromium.src,TheTypoMaster/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,TheTypoMaster/chromium-crosswalk,Just-D/chromium-1,patrickm/chromium.src,Just-D/chromium-1,fujunwei/chromium-crosswalk,anirudhSK/chromium,dushu1203/chromium.src,krieger-od/nwjs_chromium.src,littlstar/chromium.src,markYoungH/chromium.src,ltilve/chromium,axinging/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,dednal/chromium.src,hgl888/chromium-crosswalk,markYoungH/chromium.src,TheTypoMaster/chromium-crosswalk,Jonekee/chromium.src,Pluto-tv/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,Fireblend/chromium-crosswalk,dushu1203/chromium.src,hgl888/chromium-crosswalk,jaruba/chromium.src,dushu1203/chromium.src,ltilve/chromium,bright-sparks/chromium-spacewalk,ChromiumWebApps/chromium,hgl888/chromium-crosswalk-efl,Fireblend/chromium-crosswalk,mogoweb/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,anirudhSK/chromium,Just-D/chromium-1,anirudhSK/chromium,axinging/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,crosswalk-project/chromium-crosswalk-efl,mogoweb/chromium-crosswalk,dednal/chromium.src,ondra-novak/chromium.src,krieger-od/nwjs_chromium.src,mogoweb/chromium-crosswalk,dednal/chromium.src,mohamed--abdel-maksoud/chromium.src,Chilledheart/chromium,axinging/chromium-crosswalk,ondra-novak/chromium.src,chuan9/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,patrickm/chromium.src,Pluto-tv/chromium-crosswalk,bright-sparks/chromium-spacewalk,jaruba/chromium.src,Pluto-tv/chromium-crosswalk,ltilve/chromium,dednal/chromium.src,jaruba/chromium.src,TheTypoMaster/chromium-crosswalk,ChromiumWebApps/chromium,ChromiumWebApps/chromium,axinging/chromium-crosswalk,krieger-od/nwjs_chromium.src,ondra-novak/chromium.src,axinging/chromium-crosswalk,hgl888/chromium-crosswalk-efl,anirudhSK/chromium,ChromiumWebApps/chromium,mohamed--abdel-maksoud/chromium.src,TheTypoMaster/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,dushu1203/chromium.src,markYoungH/chromium.src,hgl888/chromium-crosswalk-efl,fujunwei/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,anirudhSK/chromium,patrickm/chromium.src,ondra-novak/chromium.src,dednal/chromium.src,ChromiumWebApps/chromium,patrickm/chromium.src,Just-D/chromium-1,Pluto-tv/chromium-crosswalk,hgl888/chromium-crosswalk-efl,bright-sparks/chromium-spacewalk,crosswalk-project/chromium-crosswalk-efl,axinging/chromium-crosswalk,littlstar/chromium.src,Jonekee/chromium.src,Pluto-tv/chromium-crosswalk,Jonekee/chromium.src,TheTypoMaster/chromium-crosswalk,bright-sparks/chromium-spacewalk,markYoungH/chromium.src,jaruba/chromium.src,Just-D/chromium-1,markYoungH/chromium.src,markYoungH/chromium.src,Just-D/chromium-1,Jonekee/chromium.src,Chilledheart/chromium,hgl888/chromium-crosswalk,markYoungH/chromium.src,ChromiumWebApps/chromium,PeterWangIntel/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,hgl888/chromium-crosswalk-efl,dednal/chromium.src,dednal/chromium.src,dednal/chromium.src,krieger-od/nwjs_chromium.src,Fireblend/chromium-crosswalk,littlstar/chromium.src,mohamed--abdel-maksoud/chromium.src,chuan9/chromium-crosswalk,bright-sparks/chromium-spacewalk,mogoweb/chromium-crosswalk,M4sse/chromium.src,chuan9/chromium-crosswalk,krieger-od/nwjs_chromium.src,PeterWangIntel/chromium-crosswalk,patrickm/chromium.src,axinging/chromium-crosswalk,fujunwei/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,patrickm/chromium.src,chuan9/chromium-crosswalk,chuan9/chromium-crosswalk,ltilve/chromium,ondra-novak/chromium.src,Just-D/chromium-1,dednal/chromium.src,mohamed--abdel-maksoud/chromium.src,hgl888/chromium-crosswalk,dushu1203/chromium.src
--- +++ @@ -6,7 +6,6 @@ # Add new suites here before upgrading them to the stable list below. EXPERIMENTAL_TEST_SUITES = [ - 'content_browsertests', ] # Do not modify this list without approval of an android owner. @@ -30,4 +29,5 @@ 'webkit_unit_tests', 'breakpad_unittests', 'sandbox_linux_unittests', + 'content_browsertests', ]
8abd52f37e713d9d26cccd5c073fe338145759fd
child_sync_gp/model/project_compassion.py
child_sync_gp/model/project_compassion.py
# -*- encoding: utf-8 -*- ############################################################################## # # Copyright (C) 2014-2015 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name # @author: Emanuel Cino <[email protected]> # # The licence is in the file __openerp__.py # ############################################################################## from openerp.osv import orm from . import gp_connector class project_compassion(orm.Model): _inherit = 'compassion.project' def write(self, cr, uid, ids, vals, context=None): """Update Project in GP.""" res = super(project_compassion, self).write(cr, uid, ids, vals, context) gp_connect = gp_connector.GPConnect() for project in self.browse(cr, uid, ids, context): gp_connect.upsert_project(uid, project) return res
# -*- encoding: utf-8 -*- ############################################################################## # # Copyright (C) 2014-2015 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name # @author: Emanuel Cino <[email protected]> # # The licence is in the file __openerp__.py # ############################################################################## from openerp.osv import orm from . import gp_connector class project_compassion(orm.Model): _inherit = 'compassion.project' def write(self, cr, uid, ids, vals, context=None): """Update Project in GP.""" res = super(project_compassion, self).write(cr, uid, ids, vals, context) if not isinstance(ids, list): ids = [ids] gp_connect = gp_connector.GPConnect() for project in self.browse(cr, uid, ids, context): gp_connect.upsert_project(uid, project) return res
Fix bug in write project.
Fix bug in write project.
Python
agpl-3.0
CompassionCH/compassion-switzerland,eicher31/compassion-switzerland,eicher31/compassion-switzerland,eicher31/compassion-switzerland,CompassionCH/compassion-switzerland,Secheron/compassion-switzerland,ecino/compassion-switzerland,ndtran/compassion-switzerland,MickSandoz/compassion-switzerland,Secheron/compassion-switzerland,CompassionCH/compassion-switzerland,ecino/compassion-switzerland,MickSandoz/compassion-switzerland,ndtran/compassion-switzerland,ecino/compassion-switzerland
--- +++ @@ -21,6 +21,8 @@ """Update Project in GP.""" res = super(project_compassion, self).write(cr, uid, ids, vals, context) + if not isinstance(ids, list): + ids = [ids] gp_connect = gp_connector.GPConnect() for project in self.browse(cr, uid, ids, context): gp_connect.upsert_project(uid, project)
1986000f7e3fff1366de245dadf8cd3b6e53f238
djstripe/contrib/rest_framework/permissions.py
djstripe/contrib/rest_framework/permissions.py
""" .. module:: dj-stripe.contrib.rest_framework.permissions. :synopsis: dj-stripe - Permissions to be used with the dj-stripe REST API. .. moduleauthor:: @kavdev, @pydanny """ from rest_framework.permissions import BasePermission from ...settings import subscriber_request_callback from ...utils import subscriber_has_active_subscription class DJStripeSubscriptionPermission(BasePermission): """ A permission to be used when wanting to permit users with active subscriptions. """ def has_permission(self, request, view): """ Check if the subscriber has an active subscription. Returns false if: * a subscriber isn't passed through the request See ``utils.subscriber_has_active_subscription`` for more rules. """ try: subscriber_has_active_subscription(subscriber_request_callback(request)) except AttributeError: return False
""" .. module:: dj-stripe.contrib.rest_framework.permissions. :synopsis: dj-stripe - Permissions to be used with the dj-stripe REST API. .. moduleauthor:: @kavdev, @pydanny """ from rest_framework.permissions import BasePermission from ...settings import subscriber_request_callback from ...utils import subscriber_has_active_subscription class DJStripeSubscriptionPermission(BasePermission): """ A permission to be used when wanting to permit users with active subscriptions. """ def has_permission(self, request, view) -> bool: """ Check if the subscriber has an active subscription. Returns false if: * a subscriber isn't passed through the request See ``utils.subscriber_has_active_subscription`` for more rules. """ try: return subscriber_has_active_subscription( subscriber_request_callback(request) ) except AttributeError: return False
Fix missing return statement in DJStripeSubscriptionPermission
Fix missing return statement in DJStripeSubscriptionPermission Fixes #1250
Python
mit
dj-stripe/dj-stripe,dj-stripe/dj-stripe,pydanny/dj-stripe,pydanny/dj-stripe
--- +++ @@ -17,7 +17,7 @@ A permission to be used when wanting to permit users with active subscriptions. """ - def has_permission(self, request, view): + def has_permission(self, request, view) -> bool: """ Check if the subscriber has an active subscription. @@ -28,6 +28,8 @@ """ try: - subscriber_has_active_subscription(subscriber_request_callback(request)) + return subscriber_has_active_subscription( + subscriber_request_callback(request) + ) except AttributeError: return False
25d93bf202e1735f21b6c3ad5830e660824efde6
flask_truss/blueprints/_blueprint/__init__.py
flask_truss/blueprints/_blueprint/__init__.py
from flask import Blueprint, render_template, current_app, request from flask_truss.async._task import _task from flask_truss.libs.logger import log_flask_request _blueprint = Blueprint('_blueprint', __name__, template_folder='templates') @_blueprint.route('/') def render_blueprint(): log_flask_request(current_app, request) # Call _task.delay() or _task.apply_async(...) if you've set up a broker. _task() return render_template('_blueprint.j2', content=None)
from flask import Blueprint, render_template, current_app, request from flask_truss.async._task import _task from flask_truss.lib.logger import log_flask_request _blueprint = Blueprint('_blueprint', __name__, template_folder='templates') @_blueprint.route('/') def render_blueprint(): log_flask_request(current_app, request) # Call _task.delay() or _task.apply_async(...) if you've set up a broker. _task() return render_template('_blueprint.j2', content=None)
Fix typo in imports in _blueprint. Libs -> lib
Fix typo in imports in _blueprint. Libs -> lib
Python
mit
bmoar/flask-truss,bmoar/flask-truss
--- +++ @@ -1,7 +1,7 @@ from flask import Blueprint, render_template, current_app, request from flask_truss.async._task import _task -from flask_truss.libs.logger import log_flask_request +from flask_truss.lib.logger import log_flask_request _blueprint = Blueprint('_blueprint', __name__, template_folder='templates')
94351ce09112c7bd4c9ed58722334ee48fe99883
datapackage_pipelines_fiscal/processors/upload.py
datapackage_pipelines_fiscal/processors/upload.py
import os import zipfile import tempfile from datapackage_pipelines.wrapper import ingest, spew import gobble params, datapackage, res_iter = ingest() spew(datapackage, res_iter) user = gobble.user.User() in_filename = open(params['in-file'], 'rb') in_file = zipfile.ZipFile(in_filename) temp_dir = tempfile.mkdtemp() for name in in_file.namelist(): in_file.extract(name, temp_dir) in_file.close() datapackage_json = os.path.join(temp_dir, 'datapackage.json') package = gobble.fiscal.FiscalDataPackage(datapackage_json, user=user) package.upload(skip_validation=True, publish=False)
import os import zipfile import tempfile from datapackage_pipelines.wrapper import ingest, spew import gobble params, datapackage, res_iter = ingest() spew(datapackage, res_iter) user = gobble.user.User() in_filename = open(params['in-file'], 'rb') in_file = zipfile.ZipFile(in_filename) temp_dir = tempfile.mkdtemp() for name in in_file.namelist(): in_file.extract(name, temp_dir) in_file.close() datapackage_json = os.path.join(temp_dir, 'datapackage.json') package = gobble.fiscal.FiscalDataPackage(datapackage_json, user=user) package.upload(skip_validation=True, publish=params.get('publish', False))
Set the publication with a parameter.
Set the publication with a parameter.
Python
mit
openspending/datapackage-pipelines-fiscal
--- +++ @@ -20,4 +20,4 @@ datapackage_json = os.path.join(temp_dir, 'datapackage.json') package = gobble.fiscal.FiscalDataPackage(datapackage_json, user=user) -package.upload(skip_validation=True, publish=False) +package.upload(skip_validation=True, publish=params.get('publish', False))
9c52c82fab42ee5667791fdea612bcb94b17445e
server/constants.py
server/constants.py
#!/usr/bin/env python # -*- coding: utf-8 -*- # Constants representing the setting keys for this plugin class PluginSettings: HISTOMICSTK_DEFAULT_DRAW_STYLES = 'histomicstk.default_draw_styles'
#!/usr/bin/env python # -*- coding: utf-8 -*- # Constants representing the setting keys for this plugin class PluginSettings(object): HISTOMICSTK_DEFAULT_DRAW_STYLES = 'histomicstk.default_draw_styles'
Use new-style Python 2 classes.
Use new-style Python 2 classes.
Python
apache-2.0
DigitalSlideArchive/HistomicsTK,DigitalSlideArchive/HistomicsTK
--- +++ @@ -3,5 +3,5 @@ # Constants representing the setting keys for this plugin -class PluginSettings: +class PluginSettings(object): HISTOMICSTK_DEFAULT_DRAW_STYLES = 'histomicstk.default_draw_styles'
155ab92dd2ff4340e4773e22762d52f557b300e8
dividebatur/tests/test_ticket_sort_key.py
dividebatur/tests/test_ticket_sort_key.py
from ..aecdata import ticket_sort_key def apply_ticket_sort(items): return list(sorted(items, key=ticket_sort_key)) def test_a_c_already_sorted(): assert(apply_ticket_sort(['A', 'B', 'C']) == ['A', 'B', 'C']) def test_a_c_reversed(): assert(apply_ticket_sort(['C', 'B', 'A']) == ['A', 'B', 'C']) def test_a_c_aa_reversed(): assert(apply_ticket_sort(['AA', 'C', 'B', 'A']) == ['A', 'B', 'C', 'AA']) def test_a_c_aa_already_sorted(): assert(apply_ticket_sort(['A', 'B', 'C', 'AA']) == ['A', 'B', 'C', 'AA'])
from ..aecdata.utils import ticket_sort_key def apply_ticket_sort(items): return list(sorted(items, key=ticket_sort_key)) def test_a_c_already_sorted(): assert(apply_ticket_sort(['A', 'B', 'C']) == ['A', 'B', 'C']) def test_a_c_reversed(): assert(apply_ticket_sort(['C', 'B', 'A']) == ['A', 'B', 'C']) def test_a_c_aa_reversed(): assert(apply_ticket_sort(['AA', 'C', 'B', 'A']) == ['A', 'B', 'C', 'AA']) def test_a_c_aa_already_sorted(): assert(apply_ticket_sort(['A', 'B', 'C', 'AA']) == ['A', 'B', 'C', 'AA'])
Fix import in ticket_sort_key tests.
Fix import in ticket_sort_key tests.
Python
apache-2.0
grahame/dividebatur,grahame/dividebatur,grahame/dividebatur
--- +++ @@ -1,4 +1,4 @@ -from ..aecdata import ticket_sort_key +from ..aecdata.utils import ticket_sort_key def apply_ticket_sort(items):
ec4d84e0b67d26dd9888d1b54adda6fbbcdc67da
packages/blueprints/api.py
packages/blueprints/api.py
from flask import Blueprint, render_template, abort, request, redirect, session, url_for from flask.ext.login import current_user, login_user from sqlalchemy import desc from packages.objects import * from packages.common import * from packages.config import _cfg import os import zipfile import urllib api = Blueprint('api', __name__) @api.route("/test") @json_output def test(): return { 'value': 'Hello world!' }
from flask import Blueprint, render_template, abort, request, redirect, session, url_for from flask.ext.login import current_user, login_user from sqlalchemy import desc from packages.objects import * from packages.common import * from packages.config import _cfg import os import zipfile import urllib api = Blueprint('api', __name__) @api.route("/api/v1/login", methods=['POST']) @json_output def login(): username = request.form['username'] password = request.form['password'] user = User.query.filter(User.username.ilike(username)).first() if not user: return { 'success': False, 'error': 'Your username or password is incorrect.' } if user.confirmation != '' and user.confirmation != None: return { 'success': False, 'error': 'Your account is pending. Check your email or contact [email protected]' } if not bcrypt.checkpw(password, user.password): return { 'success': False, 'error': 'Your username or password is incorrect.' } login_user(user) return { 'success': True }
Add API endpoint for logging in
Add API endpoint for logging in
Python
mit
KnightOS/packages.knightos.org,MaxLeiter/packages.knightos.org,MaxLeiter/packages.knightos.org,KnightOS/packages.knightos.org,KnightOS/packages.knightos.org,MaxLeiter/packages.knightos.org
--- +++ @@ -11,7 +11,17 @@ api = Blueprint('api', __name__) [email protected]("/test") [email protected]("/api/v1/login", methods=['POST']) @json_output -def test(): - return { 'value': 'Hello world!' } +def login(): + username = request.form['username'] + password = request.form['password'] + user = User.query.filter(User.username.ilike(username)).first() + if not user: + return { 'success': False, 'error': 'Your username or password is incorrect.' } + if user.confirmation != '' and user.confirmation != None: + return { 'success': False, 'error': 'Your account is pending. Check your email or contact [email protected]' } + if not bcrypt.checkpw(password, user.password): + return { 'success': False, 'error': 'Your username or password is incorrect.' } + login_user(user) + return { 'success': True }
58c97445c8d55d48e03498c758f7b7c6dee245aa
enabled/_50_admin_add_monitoring_panel.py
enabled/_50_admin_add_monitoring_panel.py
# The name of the panel to be added to HORIZON_CONFIG. Required. PANEL = 'monitoring' # The name of the dashboard the PANEL associated with. Required. PANEL_DASHBOARD = 'overcloud' # The name of the panel group the PANEL is associated with. #PANEL_GROUP = 'admin' # Python panel class of the PANEL to be added. ADD_PANEL = \ 'monitoring.panel.Monitoring' # A list of applications to be added to INSTALLED_APPS. ADD_INSTALLED_APPS = ['monitoring']
# The name of the panel to be added to HORIZON_CONFIG. Required. PANEL = 'monitoring' # The name of the dashboard the PANEL associated with. Required. PANEL_DASHBOARD = 'overcloud' # The name of the panel group the PANEL is associated with. #PANEL_GROUP = 'admin' DEFAULT_PANEL = 'monitoring' # Python panel class of the PANEL to be added. ADD_PANEL = \ 'monitoring.panel.Monitoring' # A list of applications to be added to INSTALLED_APPS. ADD_INSTALLED_APPS = ['monitoring'] # A list of angular modules to be added as dependencies to horizon app. #ADD_ANGULAR_MODULE = ['monitoringApp']
Set DEFAULT_PANEL to monitoring panel
Set DEFAULT_PANEL to monitoring panel
Python
apache-2.0
stackforge/monasca-ui,openstack/monasca-ui,openstack/monasca-ui,stackforge/monasca-ui,openstack/monasca-ui,openstack/monasca-ui,stackforge/monasca-ui,stackforge/monasca-ui
--- +++ @@ -4,6 +4,8 @@ PANEL_DASHBOARD = 'overcloud' # The name of the panel group the PANEL is associated with. #PANEL_GROUP = 'admin' + +DEFAULT_PANEL = 'monitoring' # Python panel class of the PANEL to be added. ADD_PANEL = \ @@ -12,3 +14,6 @@ # A list of applications to be added to INSTALLED_APPS. ADD_INSTALLED_APPS = ['monitoring'] +# A list of angular modules to be added as dependencies to horizon app. +#ADD_ANGULAR_MODULE = ['monitoringApp'] +
948c269ba191339a471844eb512448941be4497c
readthedocs/doc_builder/base.py
readthedocs/doc_builder/base.py
from functools import wraps import os from functools import wraps def restoring_chdir(fn): @wraps(fn) def decorator(*args, **kw): try: path = os.getcwd() return fn(*args, **kw) finally: os.chdir(path) return decorator class BaseBuilder(object): """ The Base for all Builders. Defines the API for subclasses. """ _changed = True @restoring_chdir def force(self, version): """ An optional step to force a build even when nothing has changed. """ print "Forcing a build by touching files" os.chdir(version.project.conf_dir(version.slug)) os.system('touch * && touch */*') def clean(self, version): """ Clean up the version so it's ready for usage. This is used to add RTD specific stuff to Sphinx, and to implement whitelists on projects as well. It is guaranteed to be called before your project is built. """ raise NotImplementedError def build(self, version): """ Do the actual building of the documentation. """ raise NotImplementedError def move(self, version): """ Move the documentation from it's generated place to its final home. This needs to understand both a single server dev environment, as well as a multi-server environment. """ raise NotImplementedError @property def changed(self): """ Says whether the documentation has changed, and requires further action. This is mainly used to short-circuit more expensive builds of other output formats if the project docs didn't change on an update. Defaults to `True` """ return self._changed
from functools import wraps import os from functools import wraps def restoring_chdir(fn): @wraps(fn) def decorator(*args, **kw): try: path = os.getcwd() return fn(*args, **kw) finally: os.chdir(path) return decorator class BaseBuilder(object): """ The Base for all Builders. Defines the API for subclasses. """ @restoring_chdir def force(self, version): """ An optional step to force a build even when nothing has changed. """ print "Forcing a build by touching files" os.chdir(version.project.conf_dir(version.slug)) os.system('touch * && touch */*') def clean(self, version): """ Clean up the version so it's ready for usage. This is used to add RTD specific stuff to Sphinx, and to implement whitelists on projects as well. It is guaranteed to be called before your project is built. """ raise NotImplementedError def build(self, version): """ Do the actual building of the documentation. """ raise NotImplementedError def move(self, version): """ Move the documentation from it's generated place to its final home. This needs to understand both a single server dev environment, as well as a multi-server environment. """ raise NotImplementedError @property def changed(self): """ Says whether the documentation has changed, and requires further action. This is mainly used to short-circuit more expensive builds of other output formats if the project docs didn't change on an update. Defaults to `True` """ return getattr(self, '_changed', True)
Kill _changed from the Base so subclassing makes more sense.
Kill _changed from the Base so subclassing makes more sense.
Python
mit
gjtorikian/readthedocs.org,cgourlay/readthedocs.org,tddv/readthedocs.org,wanghaven/readthedocs.org,asampat3090/readthedocs.org,kenwang76/readthedocs.org,KamranMackey/readthedocs.org,clarkperkins/readthedocs.org,VishvajitP/readthedocs.org,emawind84/readthedocs.org,Carreau/readthedocs.org,johncosta/private-readthedocs.org,Tazer/readthedocs.org,espdev/readthedocs.org,alex/readthedocs.org,nyergler/pythonslides,espdev/readthedocs.org,LukasBoersma/readthedocs.org,safwanrahman/readthedocs.org,mhils/readthedocs.org,GovReady/readthedocs.org,tddv/readthedocs.org,hach-que/readthedocs.org,nikolas/readthedocs.org,SteveViss/readthedocs.org,Tazer/readthedocs.org,espdev/readthedocs.org,tddv/readthedocs.org,VishvajitP/readthedocs.org,sunnyzwh/readthedocs.org,atsuyim/readthedocs.org,hach-que/readthedocs.org,wanghaven/readthedocs.org,nyergler/pythonslides,mrshoki/readthedocs.org,stevepiercy/readthedocs.org,VishvajitP/readthedocs.org,gjtorikian/readthedocs.org,kdkeyser/readthedocs.org,fujita-shintaro/readthedocs.org,KamranMackey/readthedocs.org,kenwang76/readthedocs.org,wanghaven/readthedocs.org,pombredanne/readthedocs.org,stevepiercy/readthedocs.org,kdkeyser/readthedocs.org,laplaceliu/readthedocs.org,sils1297/readthedocs.org,titiushko/readthedocs.org,agjohnson/readthedocs.org,mrshoki/readthedocs.org,SteveViss/readthedocs.org,istresearch/readthedocs.org,mhils/readthedocs.org,agjohnson/readthedocs.org,kenwang76/readthedocs.org,CedarLogic/readthedocs.org,mhils/readthedocs.org,clarkperkins/readthedocs.org,michaelmcandrew/readthedocs.org,emawind84/readthedocs.org,laplaceliu/readthedocs.org,laplaceliu/readthedocs.org,takluyver/readthedocs.org,LukasBoersma/readthedocs.org,takluyver/readthedocs.org,singingwolfboy/readthedocs.org,sid-kap/readthedocs.org,attakei/readthedocs-oauth,GovReady/readthedocs.org,kenshinthebattosai/readthedocs.org,gjtorikian/readthedocs.org,agjohnson/readthedocs.org,singingwolfboy/readthedocs.org,sunnyzwh/readthedocs.org,jerel/readthedocs.org,attakei/readthedocs-oauth,sid-kap/readthedocs.org,GovReady/readthedocs.org,raven47git/readthedocs.org,titiushko/readthedocs.org,d0ugal/readthedocs.org,davidfischer/readthedocs.org,techtonik/readthedocs.org,atsuyim/readthedocs.org,kenshinthebattosai/readthedocs.org,ojii/readthedocs.org,asampat3090/readthedocs.org,d0ugal/readthedocs.org,mhils/readthedocs.org,techtonik/readthedocs.org,wijerasa/readthedocs.org,agjohnson/readthedocs.org,alex/readthedocs.org,rtfd/readthedocs.org,ojii/readthedocs.org,michaelmcandrew/readthedocs.org,alex/readthedocs.org,wijerasa/readthedocs.org,ojii/readthedocs.org,KamranMackey/readthedocs.org,Carreau/readthedocs.org,CedarLogic/readthedocs.org,cgourlay/readthedocs.org,CedarLogic/readthedocs.org,sid-kap/readthedocs.org,safwanrahman/readthedocs.org,emawind84/readthedocs.org,Carreau/readthedocs.org,Tazer/readthedocs.org,jerel/readthedocs.org,ojii/readthedocs.org,istresearch/readthedocs.org,rtfd/readthedocs.org,davidfischer/readthedocs.org,michaelmcandrew/readthedocs.org,davidfischer/readthedocs.org,royalwang/readthedocs.org,jerel/readthedocs.org,fujita-shintaro/readthedocs.org,dirn/readthedocs.org,attakei/readthedocs-oauth,davidfischer/readthedocs.org,GovReady/readthedocs.org,kenwang76/readthedocs.org,alex/readthedocs.org,royalwang/readthedocs.org,soulshake/readthedocs.org,titiushko/readthedocs.org,istresearch/readthedocs.org,stevepiercy/readthedocs.org,LukasBoersma/readthedocs.org,wijerasa/readthedocs.org,soulshake/readthedocs.org,asampat3090/readthedocs.org,raven47git/readthedocs.org,CedarLogic/readthedocs.org,dirn/readthedocs.org,sils1297/readthedocs.org,stevepiercy/readthedocs.org,fujita-shintaro/readthedocs.org,sunnyzwh/readthedocs.org,SteveViss/readthedocs.org,clarkperkins/readthedocs.org,johncosta/private-readthedocs.org,nyergler/pythonslides,nikolas/readthedocs.org,sid-kap/readthedocs.org,dirn/readthedocs.org,espdev/readthedocs.org,atsuyim/readthedocs.org,attakei/readthedocs-oauth,soulshake/readthedocs.org,espdev/readthedocs.org,kenshinthebattosai/readthedocs.org,dirn/readthedocs.org,takluyver/readthedocs.org,singingwolfboy/readthedocs.org,rtfd/readthedocs.org,LukasBoersma/readthedocs.org,soulshake/readthedocs.org,atsuyim/readthedocs.org,kdkeyser/readthedocs.org,sils1297/readthedocs.org,wijerasa/readthedocs.org,cgourlay/readthedocs.org,wanghaven/readthedocs.org,hach-que/readthedocs.org,d0ugal/readthedocs.org,titiushko/readthedocs.org,laplaceliu/readthedocs.org,safwanrahman/readthedocs.org,VishvajitP/readthedocs.org,Carreau/readthedocs.org,techtonik/readthedocs.org,sunnyzwh/readthedocs.org,Tazer/readthedocs.org,gjtorikian/readthedocs.org,royalwang/readthedocs.org,royalwang/readthedocs.org,emawind84/readthedocs.org,nikolas/readthedocs.org,safwanrahman/readthedocs.org,michaelmcandrew/readthedocs.org,asampat3090/readthedocs.org,takluyver/readthedocs.org,techtonik/readthedocs.org,hach-que/readthedocs.org,mrshoki/readthedocs.org,cgourlay/readthedocs.org,clarkperkins/readthedocs.org,istresearch/readthedocs.org,kenshinthebattosai/readthedocs.org,kdkeyser/readthedocs.org,d0ugal/readthedocs.org,mrshoki/readthedocs.org,nikolas/readthedocs.org,raven47git/readthedocs.org,raven47git/readthedocs.org,SteveViss/readthedocs.org,sils1297/readthedocs.org,jerel/readthedocs.org,nyergler/pythonslides,KamranMackey/readthedocs.org,singingwolfboy/readthedocs.org,pombredanne/readthedocs.org,rtfd/readthedocs.org,pombredanne/readthedocs.org,johncosta/private-readthedocs.org,fujita-shintaro/readthedocs.org
--- +++ @@ -17,8 +17,6 @@ """ The Base for all Builders. Defines the API for subclasses. """ - - _changed = True @restoring_chdir def force(self, version): @@ -64,4 +62,4 @@ Defaults to `True` """ - return self._changed + return getattr(self, '_changed', True)
7cedab4826d5d184e595864f4cf5ca3966a1921e
random_object_id/random_object_id.py
random_object_id/random_object_id.py
import binascii import os import time from optparse import OptionParser def gen_random_object_id(): timestamp = '{0:x}'.format(int(time.time())) rest = binascii.b2a_hex(os.urandom(8)).decode('ascii') return timestamp + rest if __name__ == '__main__': parser = OptionParser() parser.add_option('-l', '--longform', action="store_true", dest="long_form", help="prints the ID surrounded by ObjectId(...)") (options, args) = parser.parse_args() object_id = gen_random_object_id() if options.long_form: print('ObjectId("{}")'.format(object_id)) else: print(object_id)
import binascii import os import time from argparse import ArgumentParser def gen_random_object_id(): timestamp = '{0:x}'.format(int(time.time())) rest = binascii.b2a_hex(os.urandom(8)).decode('ascii') return timestamp + rest if __name__ == '__main__': parser = ArgumentParser(description='Generate a random MongoDB ObjectId') parser.add_argument('-l', '--longform', action="store_true", dest="long_form", help="prints the ID surrounded by ObjectId(...)") args = parser.parse_args() object_id = gen_random_object_id() if args.long_form: print('ObjectId("{}")'.format(object_id)) else: print(object_id)
Use argparse instead of optparse
Use argparse instead of optparse
Python
mit
mxr/random-object-id
--- +++ @@ -2,7 +2,7 @@ import os import time -from optparse import OptionParser +from argparse import ArgumentParser def gen_random_object_id(): @@ -11,17 +11,17 @@ return timestamp + rest if __name__ == '__main__': - parser = OptionParser() - parser.add_option('-l', '--longform', - action="store_true", - dest="long_form", - help="prints the ID surrounded by ObjectId(...)") + parser = ArgumentParser(description='Generate a random MongoDB ObjectId') + parser.add_argument('-l', '--longform', + action="store_true", + dest="long_form", + help="prints the ID surrounded by ObjectId(...)") - (options, args) = parser.parse_args() + args = parser.parse_args() object_id = gen_random_object_id() - if options.long_form: + if args.long_form: print('ObjectId("{}")'.format(object_id)) else: print(object_id)
ad2fd7bf2ccfee18856e6f94b996a630ae8362ee
sharepa/__init__.py
sharepa/__init__.py
from sharepa.search import ShareSearch, basic_search # noqa from sharepa.analysis import bucket_to_dataframe, merge_dataframes # noqa def source_counts(): return bucket_to_dataframe( 'total_source_counts', basic_search.execute().aggregations.sourceAgg.buckets )
from sharepa.search import ShareSearch, basic_search # noqa from sharepa.analysis import bucket_to_dataframe, merge_dataframes # noqa def source_counts(): return bucket_to_dataframe( 'total_source_counts', ShareSearch().execute().aggregations.sourceAgg.buckets )
Make total_source_counts always be a full query
Make total_source_counts always be a full query
Python
mit
fabianvf/sharepa,CenterForOpenScience/sharepa,erinspace/sharepa,samanehsan/sharepa
--- +++ @@ -5,5 +5,5 @@ def source_counts(): return bucket_to_dataframe( 'total_source_counts', - basic_search.execute().aggregations.sourceAgg.buckets + ShareSearch().execute().aggregations.sourceAgg.buckets )
404b9208d98753dfccffb6c87594cfc70faed073
filer/tests/general.py
filer/tests/general.py
#-*- coding: utf-8 -*- from django.test import TestCase import filer class GeneralTestCase(TestCase): def test_version_is_set(self): self.assertTrue(len(filer.get_version())>0) def test_travisci_configuration(self): self.assertTrue(False)
#-*- coding: utf-8 -*- from django.test import TestCase import filer class GeneralTestCase(TestCase): def test_version_is_set(self): self.assertTrue(len(filer.get_version())>0)
Revert "travis ci: test if it REALLY works"
Revert "travis ci: test if it REALLY works" This reverts commit 78d87177c71adea7cc06d968374d2c2197dc5289.
Python
bsd-3-clause
Flight/django-filer,obigroup/django-filer,DylannCordel/django-filer,vstoykov/django-filer,o-zander/django-filer,mitar/django-filer,stefanfoulis/django-filer,skirsdeda/django-filer,thomasbilk/django-filer,kriwil/django-filer,sbussetti/django-filer,jakob-o/django-filer,lory87/django-filer,rollstudio/django-filer,Flight/django-filer,jrief/django-filer,lory87/django-filer,mitar/django-filer,pbs/django-filer,DylannCordel/django-filer,sopraux/django-filer,fusionbox/django-filer,jakob-o/django-filer,alexandrupirjol/django-filer,belimawr/django-filer,SmithsonianEnterprises/django-filer,nimbis/django-filer,obigroup/django-filer,pbs/django-filer,skirsdeda/django-filer,SmithsonianEnterprises/django-filer,rollstudio/django-filer,samastur/django-filer,mkoistinen/django-filer,20tab/django-filer,skirsdeda/django-filer,stefanfoulis/django-filer,webu/django-filer,jakob-o/django-filer,vechorko/django-filer,dbrgn/django-filer,dereknutile/django-filer,skirsdeda/django-filer,nimbis/django-filer,mbrochh/django-filer,kriwil/django-filer,SmithsonianEnterprises/django-filer,DylannCordel/django-filer,neoascetic/django-filer,lory87/django-filer,pbs/django-filer,mitar/django-filer,stefanfoulis/django-filer-travis-testing,nimbis/django-filer,matthiask/django-filer,rollstudio/django-filer,civicresourcegroup/django-filer,jrief/django-filer,belimawr/django-filer,Flight/django-filer,bogdal/django-filer,DylannCordel/django-filer,divio/django-filer,jakob-o/django-filer,maikelwever/django-filer,bogdal/django-filer,matthiask/django-filer,maykinmedia/django-filer,dereknutile/django-filer,vechorko/django-filer,maykinmedia/django-filer,sbussetti/django-filer,stefanfoulis/django-filer-travis-testing,pbs/django-filer,o-zander/django-filer,maikelwever/django-filer,sopraux/django-filer,civicresourcegroup/django-filer,DylannCordel/django-filer,fusionbox/django-filer,vechorko/django-filer,nephila/django-filer,skirsdeda/django-filer,webu/django-filer,sopraux/django-filer,neoascetic/django-filer,belimawr/django-filer,neoascetic/django-filer,mbrochh/django-filer,BertrandBordage/django-filer,matthiask/django-filer,20tab/django-filer,civicresourcegroup/django-filer,pbs/django-filer,stefanfoulis/django-filer,jakob-o/django-filer,matthiask/django-filer,kriwil/django-filer,kriwil/django-filer,sopraux/django-filer,divio/django-filer,jrief/django-filer,dbrgn/django-filer,vechorko/django-filer,divio/django-filer,writepython/django-filer,nimbis/django-filer,BertrandBordage/django-filer,nephila/django-filer,nephila/django-filer,stefanfoulis/django-filer,writepython/django-filer,mkoistinen/django-filer,mbrochh/django-filer,mkoistinen/django-filer,BertrandBordage/django-filer,thomasbilk/django-filer,writepython/django-filer,jrutila/django-filer,webu/django-filer,stefanfoulis/django-filer-travis-testing,dbrgn/django-filer,maykinmedia/django-filer,Flight/django-filer,alexandrupirjol/django-filer,vstoykov/django-filer,bogdal/django-filer,webu/django-filer,samastur/django-filer,fusionbox/django-filer,stefanfoulis/django-filer,divio/django-filer,SmithsonianEnterprises/django-filer,20tab/django-filer,thomasbilk/django-filer,o-zander/django-filer,jrutila/django-filer,obigroup/django-filer,dubizzle/django-filer,Flight/django-filer,civicresourcegroup/django-filer,lory87/django-filer,jrutila/django-filer,sbussetti/django-filer,alexandrupirjol/django-filer,vstoykov/django-filer,mkoistinen/django-filer,dubizzle/django-filer,o-zander/django-filer,belimawr/django-filer,maikelwever/django-filer,dereknutile/django-filer,dubizzle/django-filer,samastur/django-filer
--- +++ @@ -6,6 +6,3 @@ class GeneralTestCase(TestCase): def test_version_is_set(self): self.assertTrue(len(filer.get_version())>0) - - def test_travisci_configuration(self): - self.assertTrue(False)
bbe2ef061eb52113d4579eac0415c79275b04721
src/masterfile/formatters.py
src/masterfile/formatters.py
# -*- coding: utf-8 -*- # Part of the masterfile package: https://github.com/njvack/masterfile # Copyright (c) 2018 Board of Regents of the University of Wisconsin System # Written by Nate Vack <[email protected]> at the Center for Healthy Minds # at the University of Wisconsin-Madison. # Released under MIT licence; see LICENSE at the package root. """ This package contains functions for pretty-printing data — for example, converting column numbers into Excel-like column identifier strings. """ import string def index_to_column_id(number): """ Takes a zero-based index and converts it to a column identifier string such as used in Excel. Examples: 0 => A 25 => Z 26 => AA 703 => AAB """ if number < 0 or not isinstance(number, int): raise AttributeError("index_to_column_id requires a non-negative int") digits = string.ascii_uppercase parts = [] number += 1 # The algorithm works on 1-based input while number > 0: number, mod = divmod(number - 1, len(digits)) parts.insert(0, digits[mod]) return ''.join(parts)
# -*- coding: utf-8 -*- # Part of the masterfile package: https://github.com/njvack/masterfile # Copyright (c) 2018 Board of Regents of the University of Wisconsin System # Written by Nate Vack <[email protected]> at the Center for Healthy Minds # at the University of Wisconsin-Madison. # Released under MIT licence; see LICENSE at the package root. """ This package contains functions for pretty-printing data — for example, converting column numbers into Excel-like column identifier strings. """ import string def index_to_column_id(number): """ Takes a zero-based index and converts it to a column identifier string such as used in Excel. Examples: 0 => A 25 => Z 26 => AA 703 => AAB Note that this is similar to converting numbers to base-26, but not quite the same — this numbering scheme has no concept of 0. We go from "Z" to "AA" which is like going from 9 to 11 with no intervening 10. Only works for positive integers. """ if number < 0 or not isinstance(number, int): raise AttributeError("index_to_column_id requires a non-negative int") digits = string.ascii_uppercase parts = [] # The algorithm works on 1-based input, the function takes 0-based input number += 1 while number > 0: number, mod = divmod(number - 1, len(digits)) parts.insert(0, digits[mod]) return ''.join(parts)
Improve documentation for column formatter
Improve documentation for column formatter The algorithm is similar to a "convert to base X" one, except that it doesn't have a zero -- we go from "Z" to "AA" which is like going from 9 to 11. This is important enough to mention.
Python
mit
njvack/masterfile
--- +++ @@ -22,12 +22,17 @@ 25 => Z 26 => AA 703 => AAB + Note that this is similar to converting numbers to base-26, but not quite + the same — this numbering scheme has no concept of 0. We go from + "Z" to "AA" which is like going from 9 to 11 with no intervening 10. + Only works for positive integers. """ if number < 0 or not isinstance(number, int): raise AttributeError("index_to_column_id requires a non-negative int") digits = string.ascii_uppercase parts = [] - number += 1 # The algorithm works on 1-based input + # The algorithm works on 1-based input, the function takes 0-based input + number += 1 while number > 0: number, mod = divmod(number - 1, len(digits)) parts.insert(0, digits[mod])
ffb8f3f0d1fe17e13b349f8f4bae8fd9acbbd146
linter.py
linter.py
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ethan Zimmerman # Copyright (c) 2014 Ethan Zimmerman # # License: MIT # """This module exports the RamlCop plugin class.""" from SublimeLinter.lint import NodeLinter class RamlCop(NodeLinter): """Provides an interface to raml-cop.""" syntax = 'raml' cmd = 'raml-cop --no-color' version_requirement = '>= 1.0.0' regex = ( r'^\[.+:(?P<line>\d+):(?P<col>\d+)\] ' r'(?:(?P<warning>WARNING)|(?P<error>ERROR)) ' r'(?P<message>.+)' ) line_col_base = (0, 0)
# # linter.py # Linter for SublimeLinter3, a code checking framework for Sublime Text 3 # # Written by Ethan Zimmerman # Copyright (c) 2014 Ethan Zimmerman # # License: MIT # """This module exports the RamlCop plugin class.""" from SublimeLinter.lint import NodeLinter class RamlCop(NodeLinter): """Provides an interface to raml-cop.""" syntax = 'raml' cmd = 'raml-cop --no-color' version_requirement = '>= 1.0.0' regex = ( r'^\[.+:(?P<line>\d+):(?P<col>\d+)\] ' r'(?P<message>.+)' ) line_col_base = (0, 0)
Update regex to match new parser output
Update regex to match new parser output
Python
mit
thebinarypenguin/SublimeLinter-contrib-raml-cop
--- +++ @@ -22,7 +22,6 @@ version_requirement = '>= 1.0.0' regex = ( r'^\[.+:(?P<line>\d+):(?P<col>\d+)\] ' - r'(?:(?P<warning>WARNING)|(?P<error>ERROR)) ' r'(?P<message>.+)' ) line_col_base = (0, 0)
302c246d1da11282e2f6a687fb504e18f1399a84
linter.py
linter.py
# # linter.py # Linter for SublimeLinter4, a code checking framework for Sublime Text 3 # # Written by Jack Cherng # Copyright (c) 2017-2019 jfcherng # # License: MIT # from SublimeLinter.lint import Linter import sublime class Iverilog(Linter): # http://www.sublimelinter.com/en/stable/linter_attributes.html name = "iverilog" cmd = "iverilog -t null ${args}" tempfile_suffix = "verilog" multiline = True on_stderr = None # fmt: off defaults = { "selector": "source.verilog", "-I +": [], "-y +": [], } # fmt: on # there is a ":" in the filepath under Windows like C:\DIR\FILE if sublime.platform() == "windows": filepath_regex = r"[^:]+:[^:]+" else: filepath_regex = r"[^:]+" # what kind of messages should be caught? regex = ( r"(?P<file>{0}):(?P<line>\d+):\s*" r"(?:(?:(?P<warning>warning)|(?P<error>error)):)?\s*" r"(?P<message>.*)".format(filepath_regex) )
# # linter.py # Linter for SublimeLinter4, a code checking framework for Sublime Text 3 # # Written by Jack Cherng # Copyright (c) 2017-2019 jfcherng # # License: MIT # from SublimeLinter.lint import Linter import sublime class Iverilog(Linter): # http://www.sublimelinter.com/en/stable/linter_attributes.html name = "iverilog" cmd = "iverilog -i -t null ${args}" tempfile_suffix = "verilog" multiline = True on_stderr = None # fmt: off defaults = { "selector": "source.verilog", "-I +": [], "-y +": [], } # fmt: on # there is a ":" in the filepath under Windows like C:\DIR\FILE if sublime.platform() == "windows": filepath_regex = r"[^:]+:[^:]+" else: filepath_regex = r"[^:]+" # what kind of messages should be caught? regex = ( r"(?P<file>{0}):(?P<line>\d+):\s*" r"(?:(?:(?P<warning>warning)|(?P<error>error)):)?\s*" r"(?P<message>.*)".format(filepath_regex) )
Add "-i" flag to ignore module not found errors
Add "-i" flag to ignore module not found errors https://github.com/steveicarus/iverilog/pull/151 Signed-off-by: Jack Cherng <[email protected]>
Python
mit
jfcherng/SublimeLinter-contrib-iverilog,jfcherng/SublimeLinter-contrib-iverilog
--- +++ @@ -15,7 +15,7 @@ class Iverilog(Linter): # http://www.sublimelinter.com/en/stable/linter_attributes.html name = "iverilog" - cmd = "iverilog -t null ${args}" + cmd = "iverilog -i -t null ${args}" tempfile_suffix = "verilog" multiline = True on_stderr = None
90c5c9db788c0450483d71c38155fcf0a9d56220
sc2reader/engine/plugins/apm.py
sc2reader/engine/plugins/apm.py
from collections import Counter class APMTracker(object): def handleInitGame(self, event, replay): for player in replay.players: player.apm = Counter() player.aps = Counter() player.seconds_played = replay.length.seconds def handlePlayerActionEvent(self, event, replay): event.player.aps[event.second] += 1 event.player.apm[event.second/60] += 1 def handlePlayerLeaveEvent(self, event, replay): event.player.seconds_played = event.second def handleEndGame(self, event, replay): print "Handling End Game" for player in replay.players: if len(player.apm.keys()) > 0: player.avg_apm = sum(player.apm.values())/float(player.seconds_played)*60 else: player.avg_apm = 0
from collections import Counter class APMTracker(object): """ Builds ``player.aps`` and ``player.apm`` dictionaries where an action is any Selection, Hotkey, or Ability event. Also provides ``player.avg_apm`` which is defined as the sum of all the above actions divided by the number of seconds played by the player (not necessarily the whole game) multiplied by 60. APM is 0 for games under 1 minute in length. """ def handleInitGame(self, event, replay): for player in replay.players: player.apm = Counter() player.aps = Counter() player.seconds_played = replay.length.seconds def handlePlayerActionEvent(self, event, replay): event.player.aps[event.second] += 1 event.player.apm[event.second/60] += 1 def handlePlayerLeaveEvent(self, event, replay): event.player.seconds_played = event.second def handleEndGame(self, event, replay): print "Handling End Game" for player in replay.players: if len(player.apm.keys()) > 0: player.avg_apm = sum(player.aps.values())/float(player.seconds_played)*60 else: player.avg_apm = 0
Fix the engine's APM plugin and add some documentation.
Fix the engine's APM plugin and add some documentation.
Python
mit
StoicLoofah/sc2reader,vlaufer/sc2reader,ggtracker/sc2reader,GraylinKim/sc2reader,GraylinKim/sc2reader,vlaufer/sc2reader,ggtracker/sc2reader,StoicLoofah/sc2reader
--- +++ @@ -1,6 +1,16 @@ from collections import Counter class APMTracker(object): + """ + Builds ``player.aps`` and ``player.apm`` dictionaries where an action is + any Selection, Hotkey, or Ability event. + + Also provides ``player.avg_apm`` which is defined as the sum of all the + above actions divided by the number of seconds played by the player (not + necessarily the whole game) multiplied by 60. + + APM is 0 for games under 1 minute in length. + """ def handleInitGame(self, event, replay): for player in replay.players: @@ -19,6 +29,6 @@ print "Handling End Game" for player in replay.players: if len(player.apm.keys()) > 0: - player.avg_apm = sum(player.apm.values())/float(player.seconds_played)*60 + player.avg_apm = sum(player.aps.values())/float(player.seconds_played)*60 else: player.avg_apm = 0
cd1eac109ed52f34df35ecea95935b7546147c87
tests/builtins/test_sum.py
tests/builtins/test_sum.py
from .. utils import TranspileTestCase, BuiltinFunctionTestCase class SumTests(TranspileTestCase): def test_sum_list(self): self.assertCodeExecution(""" print(sum([1, 2, 3, 4, 5, 6, 7])) """) def test_sum_tuple(self): self.assertCodeExecution(""" print(sum((1, 2, 3, 4, 5, 6, 7))) """) def test_sum_iterator(self): self.assertCodeExecution(""" i = iter([1, 2]) print(sum(i)) print(sum(i)) """) def test_sum_mix_floats_and_ints(self): self.assertCodeExecution(""" print(sum([1, 1.414, 2, 3.14159])) """) class BuiltinSumFunctionTests(BuiltinFunctionTestCase, TranspileTestCase): functions = ["sum"] not_implemented = [ 'test_frozenzet', ]
from .. utils import TranspileTestCase, BuiltinFunctionTestCase class SumTests(TranspileTestCase): def test_sum_list(self): self.assertCodeExecution(""" print(sum([1, 2, 3, 4, 5, 6, 7])) print(sum([[1, 2], [3, 4], [5, 6]], [])) """) def test_sum_tuple(self): self.assertCodeExecution(""" print(sum((1, 2, 3, 4, 5, 6, 7))) """) def test_sum_iterator(self): self.assertCodeExecution(""" i = iter([1, 2]) print(sum(i)) print(sum(i)) """) def test_sum_mix_floats_and_ints(self): self.assertCodeExecution(""" print(sum([1, 1.414, 2, 3.14159])) """) def test_sum_frozenset(self): self.assertCodeExecution(""" print(sum(frozenset([1, 1.414, 2, 3.14159]))) """) def test_sum_set(self): self.assertCodeExecution(""" print(sum({1, 1.414, 2, 3.14159})) """) def test_sum_dict(self): self.assertCodeExecution(""" print(sum({1: 1.414, 2: 3.14159})) """) def test_sum_generator_expressions(self): self.assertCodeExecution(""" print(sum(x ** 2 for x in [3, 4])) """) class BuiltinSumFunctionTests(BuiltinFunctionTestCase, TranspileTestCase): functions = ["sum"] not_implemented = [ ]
Add more tests for the sum builtin
Add more tests for the sum builtin
Python
bsd-3-clause
cflee/voc,freakboy3742/voc,freakboy3742/voc,cflee/voc
--- +++ @@ -5,6 +5,7 @@ def test_sum_list(self): self.assertCodeExecution(""" print(sum([1, 2, 3, 4, 5, 6, 7])) + print(sum([[1, 2], [3, 4], [5, 6]], [])) """) def test_sum_tuple(self): @@ -24,10 +25,29 @@ print(sum([1, 1.414, 2, 3.14159])) """) + def test_sum_frozenset(self): + self.assertCodeExecution(""" + print(sum(frozenset([1, 1.414, 2, 3.14159]))) + """) + + def test_sum_set(self): + self.assertCodeExecution(""" + print(sum({1, 1.414, 2, 3.14159})) + """) + + def test_sum_dict(self): + self.assertCodeExecution(""" + print(sum({1: 1.414, 2: 3.14159})) + """) + + def test_sum_generator_expressions(self): + self.assertCodeExecution(""" + print(sum(x ** 2 for x in [3, 4])) + """) + class BuiltinSumFunctionTests(BuiltinFunctionTestCase, TranspileTestCase): functions = ["sum"] not_implemented = [ - 'test_frozenzet', ]
f3aea781c633c2ee212b59f17a6028684041568c
scripts/dbutil/clean_afos.py
scripts/dbutil/clean_afos.py
""" Clean up the AFOS database called from RUN_2AM.sh """ import psycopg2 AFOS = psycopg2.connect(database='afos', host='iemdb') acursor = AFOS.cursor() acursor.execute(""" delete from products WHERE entered < ('YESTERDAY'::date - '7 days'::interval) and entered > ('YESTERDAY'::date - '31 days'::interval) and ( pil ~* '^(RR[1-9SA]|ROB|TAF|MAV|MET|MTR|MEX|RWR|STO|HML)' or pil in ('HPTNCF', 'WTSNCF','WRKTTU','TSTNCF', 'HD3RSA') )""") if acursor.rowcount == 0: print 'clean_afos.py found no products older than 7 days?' acursor.close() AFOS.commit()
"""Clean up some tables that contain bloaty NWS Text Data called from RUN_2AM.sh """ import psycopg2 # Clean AFOS AFOS = psycopg2.connect(database='afos', host='iemdb') acursor = AFOS.cursor() acursor.execute(""" delete from products WHERE entered < ('YESTERDAY'::date - '7 days'::interval) and entered > ('YESTERDAY'::date - '31 days'::interval) and (pil ~* '^(RR[1-9SA]|ROB|TAF|MAV|MET|MTR|MEX|RWR|STO|HML)' or pil in ('HPTNCF', 'WTSNCF','WRKTTU','TSTNCF', 'HD3RSA')) """) if acursor.rowcount == 0: print 'clean_afos.py found no products older than 7 days?' acursor.close() AFOS.commit() # Clean Postgis POSTGIS = psycopg2.connect(database='postgis', host='iemdb') cursor = POSTGIS.cursor() cursor.execute("""DELETE from text_products where geom is null""") cursor.close() POSTGIS.commit()
Add purging of postgis/text_products table
Add purging of postgis/text_products table
Python
mit
akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem,akrherz/iem
--- +++ @@ -1,21 +1,30 @@ -""" - Clean up the AFOS database - called from RUN_2AM.sh +"""Clean up some tables that contain bloaty NWS Text Data + +called from RUN_2AM.sh """ import psycopg2 + +# Clean AFOS AFOS = psycopg2.connect(database='afos', host='iemdb') acursor = AFOS.cursor() acursor.execute(""" - delete from products WHERE - entered < ('YESTERDAY'::date - '7 days'::interval) and - entered > ('YESTERDAY'::date - '31 days'::interval) and - ( - pil ~* '^(RR[1-9SA]|ROB|TAF|MAV|MET|MTR|MEX|RWR|STO|HML)' - or pil in ('HPTNCF', 'WTSNCF','WRKTTU','TSTNCF', 'HD3RSA') - )""") + delete from products WHERE + entered < ('YESTERDAY'::date - '7 days'::interval) and + entered > ('YESTERDAY'::date - '31 days'::interval) and + (pil ~* '^(RR[1-9SA]|ROB|TAF|MAV|MET|MTR|MEX|RWR|STO|HML)' + or pil in ('HPTNCF', 'WTSNCF','WRKTTU','TSTNCF', 'HD3RSA')) + """) if acursor.rowcount == 0: print 'clean_afos.py found no products older than 7 days?' acursor.close() AFOS.commit() + +# Clean Postgis +POSTGIS = psycopg2.connect(database='postgis', host='iemdb') +cursor = POSTGIS.cursor() + +cursor.execute("""DELETE from text_products where geom is null""") +cursor.close() +POSTGIS.commit()
6f9b2dd428cde88418aafdf1708aefdfd047df13
test_assess_recovery.py
test_assess_recovery.py
from subprocess import CalledProcessError from textwrap import dedent from unittest import TestCase from test_recovery import ( parse_new_state_server_from_error, ) class RecoveryTestCase(TestCase): def test_parse_new_state_server_from_error(self): output = dedent(""" Waiting for address Attempting to connect to 10.0.0.202:22 Attempting to connect to 1.2.3.4:22 The fingerprint for the ECDSA key sent by the remote host is """) error = CalledProcessError(1, ['foo'], output) address = parse_new_state_server_from_error(error) self.assertEqual('1.2.3.4', address)
from subprocess import CalledProcessError from textwrap import dedent from unittest import TestCase from test_recovery import ( parse_new_state_server_from_error, ) class AssessRecoveryTestCase(TestCase): def test_parse_new_state_server_from_error(self): output = dedent(""" Waiting for address Attempting to connect to 10.0.0.202:22 Attempting to connect to 1.2.3.4:22 The fingerprint for the ECDSA key sent by the remote host is """) error = CalledProcessError(1, ['foo'], output) address = parse_new_state_server_from_error(error) self.assertEqual('1.2.3.4', address)
Rename the test case to match the renamed module.
Rename the test case to match the renamed module.
Python
agpl-3.0
mjs/juju,mjs/juju,mjs/juju,mjs/juju,mjs/juju,mjs/juju,mjs/juju
--- +++ @@ -7,7 +7,7 @@ ) -class RecoveryTestCase(TestCase): +class AssessRecoveryTestCase(TestCase): def test_parse_new_state_server_from_error(self): output = dedent("""
6c9bf9ee4428fbb3b35985d1bbd1c1e29b882f5c
appengine_django/db/creation.py
appengine_django/db/creation.py
#!/usr/bin/python2.4 # # Copyright 2008 Google Inc. # # 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 logging from django.conf import settings from django.db.backends.creation import BaseDatabaseCreation class DatabaseCreation(BaseDatabaseCreation): def create_test_db(self, *args, **kw): """Destroys the test datastore. A new store will be recreated on demand""" settings.DATABASE_SUPPORTS_TRANSACTIONS = False self.destroy_test_db() self.connection.use_test_datastore = True self.connection.flush() def destroy_test_db(self, *args, **kw): """Destroys the test datastore files.""" from appengine_django.db.base import destroy_datastore from appengine_django.db.base import get_test_datastore_paths destroy_datastore(*get_test_datastore_paths()) logging.debug("Destroyed test datastore")
#!/usr/bin/python2.4 # # Copyright 2008 Google Inc. # # 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 logging from django.conf import settings from django.db.backends.creation import BaseDatabaseCreation class DatabaseCreation(BaseDatabaseCreation): def create_test_db(self, *args, **kw): """Destroys the test datastore. A new store will be recreated on demand""" # Only needed for Django 1.1, deprecated @ 1.2. settings.DATABASE_SUPPORTS_TRANSACTIONS = False self.connection.settings_dict['SUPPORTS_TRANSACTIONS'] = False self.destroy_test_db() self.connection.use_test_datastore = True self.connection.flush() def destroy_test_db(self, *args, **kw): """Destroys the test datastore files.""" from appengine_django.db.base import destroy_datastore from appengine_django.db.base import get_test_datastore_paths destroy_datastore(*get_test_datastore_paths()) logging.debug("Destroyed test datastore")
Update SUPPORTS_TRANSACTIONS attribute to what is expected by Django 1.2.
Update SUPPORTS_TRANSACTIONS attribute to what is expected by Django 1.2. Patch contributed by Felix Leong. Thanks. Fixes Issue #162. git-svn-id: 7c59d995a3d63779dc3f8cdf6830411bfeeaa67b@109 d4307497-c249-0410-99bd-594fbd7e173e
Python
apache-2.0
wtanaka/google-app-engine-helper-for-django,clones/google-app-engine-django
--- +++ @@ -25,7 +25,9 @@ def create_test_db(self, *args, **kw): """Destroys the test datastore. A new store will be recreated on demand""" + # Only needed for Django 1.1, deprecated @ 1.2. settings.DATABASE_SUPPORTS_TRANSACTIONS = False + self.connection.settings_dict['SUPPORTS_TRANSACTIONS'] = False self.destroy_test_db() self.connection.use_test_datastore = True self.connection.flush()
69c81b16e07b67ba0a0bc8e1f55049e7987c5b8c
openstack_dashboard/dashboards/admin/instances/panel.py
openstack_dashboard/dashboards/admin/instances/panel.py
# Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, Inc. # # 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 _ import horizon class Instances(horizon.Panel): name = _("Instances") slug = 'instances' permissions = ('openstack.services.compute',) policy_rules = ((("compute", "context_is_admin"), ("compute", "compute:get_all")),)
# Copyright 2012 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Rights Reserved. # # Copyright 2012 Nebula, Inc. # # 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 _ import horizon class Instances(horizon.Panel): name = _("Instances") slug = 'instances' permissions = ('openstack.services.compute',) policy_rules = ((("compute", "context_is_admin"), ("compute", "os_compute_api:servers:detail")),)
Fix an incorrect policy rule in Admin > Instances
Fix an incorrect policy rule in Admin > Instances Change-Id: I765ae0c36d19c88138fbea9545a2ca4791377ffb Closes-Bug: #1703066
Python
apache-2.0
BiznetGIO/horizon,BiznetGIO/horizon,noironetworks/horizon,ChameleonCloud/horizon,yeming233/horizon,NeCTAR-RC/horizon,yeming233/horizon,BiznetGIO/horizon,yeming233/horizon,openstack/horizon,noironetworks/horizon,NeCTAR-RC/horizon,yeming233/horizon,ChameleonCloud/horizon,NeCTAR-RC/horizon,noironetworks/horizon,openstack/horizon,ChameleonCloud/horizon,openstack/horizon,BiznetGIO/horizon,ChameleonCloud/horizon,openstack/horizon,noironetworks/horizon,NeCTAR-RC/horizon
--- +++ @@ -26,4 +26,4 @@ slug = 'instances' permissions = ('openstack.services.compute',) policy_rules = ((("compute", "context_is_admin"), - ("compute", "compute:get_all")),) + ("compute", "os_compute_api:servers:detail")),)
5516b125bb00b928d85a044d3df777e1b0004d03
ovp_organizations/migrations/0008_auto_20161207_1941.py
ovp_organizations/migrations/0008_auto_20161207_1941.py
# -*- coding: utf-8 -*- # Generated by Django 1.10.1 on 2016-12-07 19:41 from __future__ import unicode_literals from django.db import migrations from ovp_organizations.models import Organization def add_members(apps, schema_editor): for organization in Organization.objects.all(): organization.members.add(organization.owner) def remove_members(apps, schema_editor): for organization in Organization.objects.all(): organization.members.clear() class Migration(migrations.Migration): dependencies = [ ('ovp_organizations', '0007_organization_members'), ] operations = [ migrations.RunPython(add_members, reverse_code=remove_members) ]
# -*- coding: utf-8 -*- # Generated by Django 1.10.1 on 2016-12-07 19:41 from __future__ import unicode_literals from django.db import migrations from ovp_organizations.models import Organization def add_members(apps, schema_editor): for organization in Organization.objects.only('pk', 'members').all(): organization.members.add(organization.owner) def remove_members(apps, schema_editor): for organization in Organization.objects.only('pk', 'members').all(): organization.members.clear() class Migration(migrations.Migration): dependencies = [ ('ovp_organizations', '0007_organization_members'), ] operations = [ migrations.RunPython(add_members, reverse_code=remove_members) ]
Add ".only" restriction to query on migration 0008
Add ".only" restriction to query on migration 0008
Python
agpl-3.0
OpenVolunteeringPlatform/django-ovp-organizations,OpenVolunteeringPlatform/django-ovp-organizations
--- +++ @@ -7,12 +7,12 @@ from ovp_organizations.models import Organization def add_members(apps, schema_editor): - for organization in Organization.objects.all(): + for organization in Organization.objects.only('pk', 'members').all(): organization.members.add(organization.owner) def remove_members(apps, schema_editor): - for organization in Organization.objects.all(): + for organization in Organization.objects.only('pk', 'members').all(): organization.members.clear()
8b7529551d11c67aad4729e53a2b25473599b1f7
billjobs/urls.py
billjobs/urls.py
from django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views router = routers.DefaultRouter() router.register(r'users', views.UserViewSet) urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-token-auth/', obtain_auth_token) ]
from django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf, name='generate-pdf'), url(r'^users/$', views.UserAdmin.as_view(), name='users'), url(r'^users/(?P<pk>[0-9]+)/$', views.UserAdminDetail.as_view(), name='user-detail'), url(r'^api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^api-token-auth/', obtain_auth_token) ]
Remove rest_framework routers, add urlpattern for users api
Remove rest_framework routers, add urlpattern for users api
Python
mit
ioO/billjobs
--- +++ @@ -1,9 +1,6 @@ from django.conf.urls import url, include from rest_framework.authtoken.views import obtain_auth_token from . import views - -router = routers.DefaultRouter() -router.register(r'users', views.UserViewSet) urlpatterns = [ url(r'^generate_pdf/(?P<bill_id>\d+)$', views.generate_pdf,
f8bc5893ee875a309361c26b93996917dbef3ba8
silk/webdoc/html/__init__.py
silk/webdoc/html/__init__.py
from .common import *
from .common import ( # noqa A, ABBR, ACRONYM, ADDRESS, APPLET, AREA, ARTICLE, ASIDE, AUDIO, B, BASE, BASEFONT, BDI, BDO, BIG, BLOCKQUOTE, BODY, BR, BUTTON, Body, CANVAS, CAPTION, CAT, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, CONDITIONAL_COMMENT, DATALIST, DD, DEL, DETAILS, DFN, DIALOG, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FIGCAPTION, FIGURE, FONT, FOOTER, FORM, FRAME, FRAMESET, Form, H1, H2, H3, H4, H5, H6, HEAD, HEADER, HR, HTML, HTMLDoc, Hyper, I, IFRAME, IMG, INPUT, INS, Image, Javascript, KBD, KEYGEN, LABEL, LEGEND, LI, LINK, MAIN, MAP, MARK, MENU, MENUITEM, META, METER, NAV, NBSP, NOFRAMES, NOSCRIPT, OBJECT, OL, OPTGROUP, OPTION, OUTPUT, P, PARAM, PRE, PROGRESS, Q, RP, RT, RUBY, S, SAMP, SCRIPT, SECTION, SELECT, SMALL, SOURCE, SPAN, STRIKE, STRONG, STYLE, SUB, SUMMARY, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TIME, TITLE, TR, TRACK, TT, U, UL, VAR, VIDEO, WBR, XML, XMLEntity, XMLNode, XMP, xmlescape, xmlunescape, )
Replace import * with explicit names
Replace import * with explicit names
Python
bsd-3-clause
orbnauticus/silk
--- +++ @@ -1,2 +1,140 @@ -from .common import * +from .common import ( # noqa + A, + ABBR, + ACRONYM, + ADDRESS, + APPLET, + AREA, + ARTICLE, + ASIDE, + AUDIO, + B, + BASE, + BASEFONT, + BDI, + BDO, + BIG, + BLOCKQUOTE, + BODY, + BR, + BUTTON, + Body, + CANVAS, + CAPTION, + CAT, + CENTER, + CITE, + CODE, + COL, + COLGROUP, + COMMENT, + CONDITIONAL_COMMENT, + DATALIST, + DD, + DEL, + DETAILS, + DFN, + DIALOG, + DIR, + DIV, + DL, + DT, + EM, + EMBED, + FIELDSET, + FIGCAPTION, + FIGURE, + FONT, + FOOTER, + FORM, + FRAME, + FRAMESET, + Form, + H1, + H2, + H3, + H4, + H5, + H6, + HEAD, + HEADER, + HR, + HTML, + HTMLDoc, + Hyper, + I, + IFRAME, + IMG, + INPUT, + INS, + Image, + Javascript, + KBD, + KEYGEN, + LABEL, + LEGEND, + LI, + LINK, + MAIN, + MAP, + MARK, + MENU, + MENUITEM, + META, + METER, + NAV, + NBSP, + NOFRAMES, + NOSCRIPT, + OBJECT, + OL, + OPTGROUP, + OPTION, + OUTPUT, + P, + PARAM, + PRE, + PROGRESS, + Q, + RP, + RT, + RUBY, + S, + SAMP, + SCRIPT, + SECTION, + SELECT, + SMALL, + SOURCE, + SPAN, + STRIKE, + STRONG, + STYLE, + SUB, + SUMMARY, + SUP, + TABLE, + TBODY, + TD, + TEXTAREA, + TFOOT, + TH, + THEAD, + TIME, + TITLE, + TR, + TRACK, + TT, + U, + UL, + VAR, + VIDEO, + WBR, + XML, + XMLEntity, + XMLNode, + XMP, + xmlescape, + xmlunescape, +)
4ec16018192c1bd8fbe60a9e4c410c6c898149f0
server/ec2spotmanager/migrations/0007_instance_type_to_list.py
server/ec2spotmanager/migrations/0007_instance_type_to_list.py
# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2018-02-28 16:47 from __future__ import unicode_literals from django.db import migrations, models def instance_types_to_list(apps, schema_editor): PoolConfiguration = apps.get_model("ec2spotmanager", "PoolConfiguration") for pool in PoolConfiguration.objects.all(): pool.ec2_instance_types_list = [pool.ec2_instance_types] pool.save() class Migration(migrations.Migration): dependencies = [ ('ec2spotmanager', '0006_auto_20150625_2050'), ] operations = [ migrations.AlterField( model_name='poolconfiguration', name='ec2_instance_type', field=models.CharField(blank=True, max_length=1023, null=True), ), migrations.RenameField( model_name='poolconfiguration', old_name='ec2_instance_type', new_name='ec2_instance_types', ), migrations.RunPython(instance_types_to_list), ]
# -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2018-02-28 16:47 from __future__ import print_function, unicode_literals import json import sys from django.db import migrations, models def instance_type_to_list(apps, schema_editor): PoolConfiguration = apps.get_model("ec2spotmanager", "PoolConfiguration") for pool in PoolConfiguration.objects.all(): if pool.ec2_instance_type: pool.ec2_instance_type = json.dumps([pool.ec2_instance_type]) pool.save() def instance_type_from_list(apps, schema_editor): PoolConfiguration = apps.get_model("ec2spotmanager", "PoolConfiguration") for pool in PoolConfiguration.objects.all(): if pool.ec2_instance_types: types = json.loads(pool.ec2_instance_types) if len(types) > 1: print("pool %d had instance types %r, choosing %s for reverse migration" % (pool.id, types, types[0]), file=sys.stderr) pool.ec2_instance_types = types[0] pool.save() class Migration(migrations.Migration): dependencies = [ ('ec2spotmanager', '0006_auto_20150625_2050'), ] operations = [ migrations.AlterField( model_name='poolconfiguration', name='ec2_instance_type', field=models.CharField(blank=True, max_length=1023, null=True), ), migrations.RunPython( code=instance_type_to_list, reverse_code=instance_type_from_list, ), migrations.RenameField( model_name='poolconfiguration', old_name='ec2_instance_type', new_name='ec2_instance_types', ), ]
Fix migration. Custom triggers are not run in data migrations.
Fix migration. Custom triggers are not run in data migrations.
Python
mpl-2.0
MozillaSecurity/FuzzManager,MozillaSecurity/FuzzManager,MozillaSecurity/FuzzManager,MozillaSecurity/FuzzManager
--- +++ @@ -1,15 +1,30 @@ # -*- coding: utf-8 -*- # Generated by Django 1.11.5 on 2018-02-28 16:47 -from __future__ import unicode_literals +from __future__ import print_function, unicode_literals +import json +import sys from django.db import migrations, models -def instance_types_to_list(apps, schema_editor): +def instance_type_to_list(apps, schema_editor): PoolConfiguration = apps.get_model("ec2spotmanager", "PoolConfiguration") for pool in PoolConfiguration.objects.all(): - pool.ec2_instance_types_list = [pool.ec2_instance_types] - pool.save() + if pool.ec2_instance_type: + pool.ec2_instance_type = json.dumps([pool.ec2_instance_type]) + pool.save() + + +def instance_type_from_list(apps, schema_editor): + PoolConfiguration = apps.get_model("ec2spotmanager", "PoolConfiguration") + for pool in PoolConfiguration.objects.all(): + if pool.ec2_instance_types: + types = json.loads(pool.ec2_instance_types) + if len(types) > 1: + print("pool %d had instance types %r, choosing %s for reverse migration" % (pool.id, types, types[0]), + file=sys.stderr) + pool.ec2_instance_types = types[0] + pool.save() class Migration(migrations.Migration): @@ -24,10 +39,13 @@ name='ec2_instance_type', field=models.CharField(blank=True, max_length=1023, null=True), ), + migrations.RunPython( + code=instance_type_to_list, + reverse_code=instance_type_from_list, + ), migrations.RenameField( model_name='poolconfiguration', old_name='ec2_instance_type', new_name='ec2_instance_types', ), - migrations.RunPython(instance_types_to_list), ]
9d4b85cdad969dfeb8e9bee1203eb9c916849b1a
wafer/sponsors/views.py
wafer/sponsors/views.py
from django.views.generic.list import ListView from django.views.generic import DetailView from rest_framework import viewsets from rest_framework.permissions import DjangoModelPermissionsOrAnonReadOnly from wafer.sponsors.models import Sponsor, SponsorshipPackage from wafer.sponsors.serializers import SponsorSerializer, PackageSerializer class ShowSponsors(ListView): template_name = 'wafer.sponsors/sponsors.html' model = Sponsor def get_queryset(self): return Sponsor.objects.all().order_by('packages', 'id') class SponsorView(DetailView): template_name = 'wafer.sponsors/sponsor.html' model = Sponsor class ShowPackages(ListView): template_name = 'wafer.sponsors/packages.html' model = SponsorshipPackage class SponsorViewSet(viewsets.ModelViewSet): """API endpoint for users.""" queryset = Sponsor.objects.all() serializer_class = SponsorSerializer permission_classes = (DjangoModelPermissionsOrAnonReadOnly, ) class PackageViewSet(viewsets.ModelViewSet): """API endpoint for users.""" queryset = SponsorshipPackage.objects.all() serializer_class = PackageSerializer permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
from django.views.generic.list import ListView from django.views.generic import DetailView from rest_framework import viewsets from rest_framework.permissions import DjangoModelPermissionsOrAnonReadOnly from wafer.sponsors.models import Sponsor, SponsorshipPackage from wafer.sponsors.serializers import SponsorSerializer, PackageSerializer class ShowSponsors(ListView): template_name = 'wafer.sponsors/sponsors.html' model = Sponsor def get_queryset(self): return Sponsor.objects.all().order_by('packages', 'order', 'id') class SponsorView(DetailView): template_name = 'wafer.sponsors/sponsor.html' model = Sponsor class ShowPackages(ListView): template_name = 'wafer.sponsors/packages.html' model = SponsorshipPackage class SponsorViewSet(viewsets.ModelViewSet): """API endpoint for users.""" queryset = Sponsor.objects.all() serializer_class = SponsorSerializer permission_classes = (DjangoModelPermissionsOrAnonReadOnly, ) class PackageViewSet(viewsets.ModelViewSet): """API endpoint for users.""" queryset = SponsorshipPackage.objects.all() serializer_class = PackageSerializer permission_classes = (DjangoModelPermissionsOrAnonReadOnly, )
Use order in all sponsors view query
Use order in all sponsors view query
Python
isc
CTPUG/wafer,CTPUG/wafer,CTPUG/wafer,CTPUG/wafer
--- +++ @@ -13,7 +13,7 @@ model = Sponsor def get_queryset(self): - return Sponsor.objects.all().order_by('packages', 'id') + return Sponsor.objects.all().order_by('packages', 'order', 'id') class SponsorView(DetailView):
19cd85215a7a305e6f253405a88d087aef114811
candidates/tests/test_constituencies_view.py
candidates/tests/test_constituencies_view.py
import re from django_webtest import WebTest class TestConstituencyDetailView(WebTest): def test_constituencies_page(self): # Just a smoke test to check that the page loads: response = self.app.get('/constituencies') aberdeen_north = response.html.find( 'a', text=re.compile(r'York Outer') ) self.assertTrue(aberdeen_north)
import re from mock import patch from django_webtest import WebTest class TestConstituencyDetailView(WebTest): @patch('candidates.popit.PopIt') def test_constituencies_page(self, mock_popit): # Just a smoke test to check that the page loads: response = self.app.get('/constituencies') aberdeen_north = response.html.find( 'a', text=re.compile(r'York Outer') ) self.assertTrue(aberdeen_north)
Make test_constituencies_page work without PopIt
Make test_constituencies_page work without PopIt
Python
agpl-3.0
DemocracyClub/yournextrepresentative,mysociety/yournextrepresentative,mysociety/yournextmp-popit,neavouli/yournextrepresentative,DemocracyClub/yournextrepresentative,YoQuieroSaber/yournextrepresentative,mysociety/yournextrepresentative,YoQuieroSaber/yournextrepresentative,YoQuieroSaber/yournextrepresentative,openstate/yournextrepresentative,mysociety/yournextmp-popit,mysociety/yournextrepresentative,YoQuieroSaber/yournextrepresentative,mysociety/yournextmp-popit,neavouli/yournextrepresentative,datamade/yournextmp-popit,datamade/yournextmp-popit,datamade/yournextmp-popit,openstate/yournextrepresentative,openstate/yournextrepresentative,openstate/yournextrepresentative,neavouli/yournextrepresentative,mysociety/yournextmp-popit,neavouli/yournextrepresentative,YoQuieroSaber/yournextrepresentative,datamade/yournextmp-popit,DemocracyClub/yournextrepresentative,datamade/yournextmp-popit,mysociety/yournextrepresentative,mysociety/yournextrepresentative,mysociety/yournextmp-popit,openstate/yournextrepresentative,neavouli/yournextrepresentative
--- +++ @@ -1,10 +1,13 @@ import re + +from mock import patch from django_webtest import WebTest class TestConstituencyDetailView(WebTest): - def test_constituencies_page(self): + @patch('candidates.popit.PopIt') + def test_constituencies_page(self, mock_popit): # Just a smoke test to check that the page loads: response = self.app.get('/constituencies') aberdeen_north = response.html.find(
09b1830f1f8683f73ef0ad111155c8d0aa75e5e2
settings_unittest.py
settings_unittest.py
from settings_common import * DEBUG = TEMPLATE_DEBUG = True DATABASE_ENGINE = 'sqlite3' DAISY_PIPELINE_PATH = os.path.join(PROJECT_DIR, '..', '..', 'tmp', 'pipeline-20090410')
from settings_common import * DEBUG = TEMPLATE_DEBUG = False DATABASE_ENGINE = 'sqlite3' TEST_DATABASE_NAME = 'unittest.db' DAISY_PIPELINE_PATH = os.path.join(PROJECT_DIR, '..', '..', 'tmp', 'pipeline-20090410')
Disable debug for unit test and specify a test db name.
Disable debug for unit test and specify a test db name.
Python
agpl-3.0
sbsdev/daisyproducer,sbsdev/daisyproducer,sbsdev/daisyproducer,sbsdev/daisyproducer
--- +++ @@ -1,7 +1,8 @@ from settings_common import * -DEBUG = TEMPLATE_DEBUG = True +DEBUG = TEMPLATE_DEBUG = False DATABASE_ENGINE = 'sqlite3' +TEST_DATABASE_NAME = 'unittest.db' DAISY_PIPELINE_PATH = os.path.join(PROJECT_DIR, '..', '..', 'tmp', 'pipeline-20090410')
a4585dc9a0d30b223db14755a00df79b96dd1f28
site/threads/urls.py
site/threads/urls.py
from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.post_list.as_view()), url(r'/?P<id>[0-9]/$', views.post_detail.as_view()) ]
from django.conf.urls import url from . import views urlpatterns = [ url(r'^$', views.post_list.as_view()), url(r'P<id>[0-9]/$', views.post_detail.as_view()) ]
Remove leading slash from URL.
Remove leading slash from URL.
Python
mit
annaelde/forum-app,annaelde/forum-app,annaelde/forum-app
--- +++ @@ -3,5 +3,5 @@ urlpatterns = [ url(r'^$', views.post_list.as_view()), - url(r'/?P<id>[0-9]/$', views.post_detail.as_view()) + url(r'P<id>[0-9]/$', views.post_detail.as_view()) ]
723a102d6272e7ba4b9df405b7c1493c34ac5b77
masters/master.chromium.fyi/master_site_config.py
masters/master.chromium.fyi/master_site_config.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. """ActiveMaster definition.""" from config_bootstrap import Master class ChromiumFYI(Master.Master1): project_name = 'Chromium FYI' master_port = 8011 slave_port = 8111 master_port_alt = 8211 buildbot_url = 'http://build.chromium.org/p/chromium.fyi/' reboot_on_step_timeout = True pubsub_service_account_file = 'service-account-pubsub.json' pubsub_topic_url = 'projects/luci-milo/topics/public-buildbot' name = 'chromium.fyi'
# 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. """ActiveMaster definition.""" from config_bootstrap import Master class ChromiumFYI(Master.Master1): project_name = 'Chromium FYI' master_port = 8011 slave_port = 8111 master_port_alt = 8211 buildbot_url = 'http://build.chromium.org/p/chromium.fyi/' reboot_on_step_timeout = True
Revert pubsub roll on FYI
Revert pubsub roll on FYI BUG= TBR=estaab Review URL: https://codereview.chromium.org/1688503002 git-svn-id: 239fca9b83025a0b6f823aeeca02ba5be3d9fd76@298680 0039d316-1c4b-4281-b951-d872f2087c98
Python
bsd-3-clause
eunchong/build,eunchong/build,eunchong/build,eunchong/build
--- +++ @@ -13,6 +13,3 @@ master_port_alt = 8211 buildbot_url = 'http://build.chromium.org/p/chromium.fyi/' reboot_on_step_timeout = True - pubsub_service_account_file = 'service-account-pubsub.json' - pubsub_topic_url = 'projects/luci-milo/topics/public-buildbot' - name = 'chromium.fyi'
39d3f605d240a8abef22107424ec1d6f76161580
static_precompiler/models.py
static_precompiler/models.py
from django.db import models class Dependency(models.Model): source = models.CharField(max_length=255, db_index=True) depends_on = models.CharField(max_length=255, db_index=True) class Meta: unique_together = ("source", "depends_on")
from __future__ import unicode_literals from django.db import models class Dependency(models.Model): source = models.CharField(max_length=255, db_index=True) depends_on = models.CharField(max_length=255, db_index=True) class Meta: unique_together = ("source", "depends_on") def __unicode__(self): return "{0} depends on {1}".format(self.source, self.depends_on)
Add __unicode__ to Dependency model
Add __unicode__ to Dependency model
Python
mit
jaheba/django-static-precompiler,jaheba/django-static-precompiler,paera/django-static-precompiler,liumengjun/django-static-precompiler,jaheba/django-static-precompiler,liumengjun/django-static-precompiler,paera/django-static-precompiler,liumengjun/django-static-precompiler,liumengjun/django-static-precompiler,liumengjun/django-static-precompiler,paera/django-static-precompiler,paera/django-static-precompiler,jaheba/django-static-precompiler
--- +++ @@ -1,3 +1,4 @@ +from __future__ import unicode_literals from django.db import models @@ -8,3 +9,6 @@ class Meta: unique_together = ("source", "depends_on") + + def __unicode__(self): + return "{0} depends on {1}".format(self.source, self.depends_on)
d2051073d48873408a711b56676ee099e5ff685a
sunpy/timeseries/__init__.py
sunpy/timeseries/__init__.py
""" SunPy's TimeSeries module provides a datatype for 1D time series data, replacing the SunPy LightCurve module. Currently the objects can be instansiated from files (such as CSV and FITS) and urls to these files, but don't include data downloaders for their specific instruments as this will become part of the universal downloader. """ from __future__ import absolute_import from sunpy.timeseries.metadata import TimeSeriesMetaData from sunpy.timeseries.timeseries_factory import TimeSeries from sunpy.timeseries.timeseriesbase import GenericTimeSeries from sunpy.timeseries.sources.eve import EVESpWxTimeSeries from sunpy.timeseries.sources.goes import XRSTimeSeries from sunpy.timeseries.sources.noaa import NOAAIndicesTimeSeries, NOAAPredictIndicesTimeSeries from sunpy.timeseries.sources.lyra import LYRATimeSeries from sunpy.timeseries.sources.norh import NoRHTimeSeries from sunpy.timeseries.sources.rhessi import RHESSISummaryTimeSeries from sunpy.timeseries.sources.fermi_gbm import GBMSummaryTimeSeries
""" SunPy's TimeSeries module provides a datatype for 1D time series data, replacing the SunPy LightCurve module. Currently the objects can be instansiated from files (such as CSV and FITS) and urls to these files, but don't include data downloaders for their specific instruments as this will become part of the universal downloader. """ from __future__ import absolute_import from sunpy.timeseries.metadata import TimeSeriesMetaData from sunpy.timeseries.timeseries_factory import TimeSeries from sunpy.timeseries.timeseriesbase import GenericTimeSeries from sunpy.timeseries.sources.eve import EVESpWxTimeSeries from sunpy.timeseries.sources.goes import XRSTimeSeries from sunpy.timeseries.sources.noaa import NOAAIndicesTimeSeries, NOAAPredictIndicesTimeSeries from sunpy.timeseries.sources.lyra import LYRATimeSeries from sunpy.timeseries.sources.norh import NoRHTimeSeries from sunpy.timeseries.sources.rhessi import RHESSISummaryTimeSeries from sunpy.timeseries.sources.fermi_gbm import GBMSummaryTimeSeries # register pandas datetime converter with matplotlib # This is to work around the change in pandas-dev/pandas#17710 import pandas.plotting._converter pandas.plotting._converter.register()
Fix matplotlib / pandas 0.21 bug in examples
Fix matplotlib / pandas 0.21 bug in examples Here we manually register the pandas matplotlib converters so people doing manual plotting with pandas works under pandas 0.21
Python
bsd-2-clause
dpshelio/sunpy,dpshelio/sunpy,dpshelio/sunpy
--- +++ @@ -14,3 +14,8 @@ from sunpy.timeseries.sources.norh import NoRHTimeSeries from sunpy.timeseries.sources.rhessi import RHESSISummaryTimeSeries from sunpy.timeseries.sources.fermi_gbm import GBMSummaryTimeSeries + +# register pandas datetime converter with matplotlib +# This is to work around the change in pandas-dev/pandas#17710 +import pandas.plotting._converter +pandas.plotting._converter.register()
dae3f42c6f6800181bc1d9f2e98cbacf03849431
scripts/create_heatmap.py
scripts/create_heatmap.py
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import os sys.path.append(os.path.dirname(os.path.dirname(__file__)) + '/src') import DataVisualizing if len(sys.argv) != 2: print 'usage: create_heatmap.py <data file>' print ' expected infile is a datafile containing tracking data' print ' this is a csv file with the following columns:' print ' cartodb_id, date_time, day_of_year, distance_from_nest_in_meters' sys.exit(-1) def main(): dvis = DataVisualizing.TrackingVisualizer(infile=sys.argv[1]) print ('var day_month_heatdata = {0};'.format(dvis.as_heatmap_json(domain='month', agg_function='max'))) print ('var hour_month_heatdata = {0};'.format(dvis.as_heatmap_json(domain='month', subdomain='hour', agg_function='max'))) main()
#!/usr/bin/python # -*- coding: utf-8 -*- import sys import os sys.path.append(os.path.dirname(os.path.dirname(__file__)) + '/src') import DataVisualizing if len(sys.argv) != 2: print 'usage: create_heatmap.py <data file>' print ' expected infile is a datafile containing tracking data' print ' this is a csv file with the following columns:' print ' cartodb_id, date_time, day_of_year, distance_from_nest_in_meters' sys.exit(-1) def main(): dvis = DataVisualizing.TrackingVisualizer(infile=sys.argv[1]) print ('var day_month_heatdata = {0};'.format(dvis.as_heatmap_json(domain='month', agg_function='max'))) print ('var hour_month_heatdata = {0};'.format(dvis.as_heatmap_json(domain='month', subdomain='hour', agg_function='max'))) print ('var hour_month_linedata = [ {{ \'key\': \'Maximum distance\', \'color\': \'green\', \'values\': {0} }} ];'.format(dvis.as_raw_line_json(agg_function='max'))) main()
Add raw line data to output
Add raw line data to output
Python
mit
LifeWatchINBO/bird-tracking,LifeWatchINBO/bird-tracking
--- +++ @@ -17,5 +17,6 @@ dvis = DataVisualizing.TrackingVisualizer(infile=sys.argv[1]) print ('var day_month_heatdata = {0};'.format(dvis.as_heatmap_json(domain='month', agg_function='max'))) print ('var hour_month_heatdata = {0};'.format(dvis.as_heatmap_json(domain='month', subdomain='hour', agg_function='max'))) + print ('var hour_month_linedata = [ {{ \'key\': \'Maximum distance\', \'color\': \'green\', \'values\': {0} }} ];'.format(dvis.as_raw_line_json(agg_function='max'))) main()
2de7222ffd3d9f4cc7971ad142aa2542eb7ca117
yunity/stores/models.py
yunity/stores/models.py
from config import settings from yunity.base.base_models import BaseModel, LocationModel from django.db import models class PickupDate(BaseModel): date = models.DateTimeField() collectors = models.ManyToManyField(settings.AUTH_USER_MODEL) store = models.ForeignKey('stores.store', related_name='pickupdates', on_delete=models.CASCADE) max_collectors = models.IntegerField(null=True) class Store(BaseModel, LocationModel): group = models.ForeignKey('groups.Group', on_delete=models.CASCADE) name = models.TextField() description = models.TextField(null=True)
from config import settings from yunity.base.base_models import BaseModel, LocationModel from django.db import models class PickupDate(BaseModel): date = models.DateTimeField() collectors = models.ManyToManyField(settings.AUTH_USER_MODEL) store = models.ForeignKey('stores.store', related_name='pickupdates', on_delete=models.CASCADE) max_collectors = models.IntegerField(null=True) class Store(BaseModel, LocationModel): group = models.ForeignKey('groups.Group', on_delete=models.CASCADE, related_name='store') name = models.TextField() description = models.TextField(null=True)
Add related name for group of store
Add related name for group of store
Python
agpl-3.0
yunity/yunity-core,yunity/foodsaving-backend,yunity/yunity-core,yunity/foodsaving-backend,yunity/foodsaving-backend
--- +++ @@ -11,6 +11,6 @@ class Store(BaseModel, LocationModel): - group = models.ForeignKey('groups.Group', on_delete=models.CASCADE) + group = models.ForeignKey('groups.Group', on_delete=models.CASCADE, related_name='store') name = models.TextField() description = models.TextField(null=True)
77ae27596c96ef5b8c05fcd02448576b419de074
config.py
config.py
class Config: SECRET_KEY = 'jsA5!@z1' class DevelopmentConfig(Config): DEBUG = True SQLALCHEMY_DATABASE_URI = "postgresql://admin:adminpass@localhost/fastmonkeys" config = { 'development': DevelopmentConfig }
class Config: SECRET_KEY = 'jsA5!@z1' class DevelopmentConfig(Config): DEBUG = True SQLALCHEMY_DATABASE_URI = "postgresql://admin:adminpass@localhost/fastmonkeys" SQLALCHEMY_COMMIT_ON_TEARDOWN = True config = { 'development': DevelopmentConfig }
Add SQLAlchemy commit on after request end
Add SQLAlchemy commit on after request end
Python
mit
timzdevz/fm-flask-app
--- +++ @@ -4,6 +4,7 @@ class DevelopmentConfig(Config): DEBUG = True SQLALCHEMY_DATABASE_URI = "postgresql://admin:adminpass@localhost/fastmonkeys" + SQLALCHEMY_COMMIT_ON_TEARDOWN = True config = { 'development': DevelopmentConfig
a475fc39480b52d4f38d37e58b3e3c45e8335a1e
tagalog/command/logship.py
tagalog/command/logship.py
from __future__ import print_function, unicode_literals import argparse import json import sys import textwrap from tagalog import io, stamp, tag from tagalog import shipper parser = argparse.ArgumentParser(description=textwrap.dedent(""" Ship log data from STDIN to somewhere else, timestamping and preprocessing each log entry into a JSON document along the way.""")) parser.add_argument('-t', '--tags', nargs='+') parser.add_argument('-s', '--shipper', default='redis') parser.add_argument('-k', '--key', default='logs') parser.add_argument('-u', '--urls', nargs='+', default=['redis://localhost:6379']) parser.add_argument('--no-stamp', action='store_true') def main(): args = parser.parse_args() shpr = shipper.get_shipper(args.shipper)(args) msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) for msg in msgs: shpr.ship(json.dumps(msg)) if __name__ == '__main__': main()
from __future__ import print_function, unicode_literals import argparse import json import sys import textwrap from tagalog import io, stamp, tag from tagalog import shipper parser = argparse.ArgumentParser(description=textwrap.dedent(""" Ship log data from STDIN to somewhere else, timestamping and preprocessing each log entry into a JSON document along the way.""")) parser.add_argument('-t', '--tags', nargs='+', help='Tag each request with the specified string tags') parser.add_argument('-s', '--shipper', default='redis', help='Select the shipper to be used to ship logs') parser.add_argument('--no-stamp', action='store_true') parser.add_argument('--bulk', action='store_true', help='Send log data in elasticsearch bulk format') parser.add_argument('--bulk-index', default='logs', help='Name of the elasticsearch index (default: logs)') parser.add_argument('--bulk-type', default='message', help='Name of the elasticsearch type (default: message)') # TODO: make these the responsibility of the redis shipper parser.add_argument('-k', '--key', default='logs') parser.add_argument('-u', '--urls', nargs='+', default=['redis://localhost:6379']) def main(): args = parser.parse_args() shpr = shipper.get_shipper(args.shipper)(args) msgs = io.messages(sys.stdin) if not args.no_stamp: msgs = stamp(msgs) if args.tags: msgs = tag(msgs, args.tags) for msg in msgs: payload = json.dumps(msg) if args.bulk: command = json.dumps({'index': {'_index': args.bulk_index, '_type': args.bulk_type}}) payload = '{0}\n{1}\n'.format(command, payload) shpr.ship(payload) if __name__ == '__main__': main()
Add support for elasticsearch bulk format
Add support for elasticsearch bulk format Add a switch to logship to enable support for sending log data in elasticsearch bulk format.
Python
mit
nickstenning/tagalog,nickstenning/tagalog,alphagov/tagalog,alphagov/tagalog
--- +++ @@ -10,11 +10,21 @@ parser = argparse.ArgumentParser(description=textwrap.dedent(""" Ship log data from STDIN to somewhere else, timestamping and preprocessing each log entry into a JSON document along the way.""")) -parser.add_argument('-t', '--tags', nargs='+') -parser.add_argument('-s', '--shipper', default='redis') +parser.add_argument('-t', '--tags', nargs='+', + help='Tag each request with the specified string tags') +parser.add_argument('-s', '--shipper', default='redis', + help='Select the shipper to be used to ship logs') +parser.add_argument('--no-stamp', action='store_true') +parser.add_argument('--bulk', action='store_true', + help='Send log data in elasticsearch bulk format') +parser.add_argument('--bulk-index', default='logs', + help='Name of the elasticsearch index (default: logs)') +parser.add_argument('--bulk-type', default='message', + help='Name of the elasticsearch type (default: message)') + +# TODO: make these the responsibility of the redis shipper parser.add_argument('-k', '--key', default='logs') parser.add_argument('-u', '--urls', nargs='+', default=['redis://localhost:6379']) -parser.add_argument('--no-stamp', action='store_true') def main(): args = parser.parse_args() @@ -26,7 +36,11 @@ if args.tags: msgs = tag(msgs, args.tags) for msg in msgs: - shpr.ship(json.dumps(msg)) + payload = json.dumps(msg) + if args.bulk: + command = json.dumps({'index': {'_index': args.bulk_index, '_type': args.bulk_type}}) + payload = '{0}\n{1}\n'.format(command, payload) + shpr.ship(payload) if __name__ == '__main__': main()
667182bf3460e2237255b00b0eea20a1cf4a83ab
app/main/views/feedback.py
app/main/views/feedback.py
import requests from werkzeug.exceptions import ServiceUnavailable from werkzeug.datastructures import MultiDict from werkzeug.urls import url_parse from flask import current_app, request, redirect, flash, Markup from .. import main @main.route('/feedback', methods=["POST"]) def send_feedback(): feedback_config = current_app.config['DM_FEEDBACK_FORM'] form_data = MultiDict() for field, google_form_field in feedback_config['fields'].items(): form_data.setlist(google_form_field, request.form.getlist(field)) result = requests.post(feedback_config['uri'], list(form_data.iteritems(multi=True))) if result.status_code != 200: raise ServiceUnavailable('Google forms submission problem (status %d)'.format(result.status_code)) came_from = url_parse(request.form['uri']) # strip netloc and scheme as we should ignore attempts to make us redirect elsewhere replaced = came_from._replace(scheme='', netloc='') flash(Markup( """Thank you for your message. If you have more extensive feedback, please <a href="mailto:[email protected]">email us</a> or <a href="https://airtable.com/shrkFM8L6Wfenzn5Q">take part in our research</a>. """)) return redirect(replaced, code=303)
import requests from werkzeug.exceptions import ServiceUnavailable from werkzeug.datastructures import MultiDict from werkzeug.urls import url_parse from flask import current_app, request, redirect, flash, Markup from .. import main @main.route('/feedback', methods=["POST"]) def send_feedback(): feedback_config = current_app.config['DM_FEEDBACK_FORM'] form_data = MultiDict() for field, google_form_field in feedback_config['fields'].items(): form_data.setlist(google_form_field, request.form.getlist(field)) result = requests.post(feedback_config['uri'], list(form_data.items(multi=True))) if result.status_code != 200: raise ServiceUnavailable('Google forms submission problem (status %d)'.format(result.status_code)) came_from = url_parse(request.form['uri']) # strip netloc and scheme as we should ignore attempts to make us redirect elsewhere replaced = came_from._replace(scheme='', netloc='') flash(Markup( """Thank you for your message. If you have more extensive feedback, please <a href="mailto:[email protected]">email us</a> or <a href="https://airtable.com/shrkFM8L6Wfenzn5Q">take part in our research</a>. """)) return redirect(replaced, code=303)
Fix broken submission on Python 3.
Fix broken submission on Python 3. - this breaks Python 2, but we don't care any more. https://trello.com/c/Uak7y047/8-feedback-forms
Python
mit
alphagov/digitalmarketplace-buyer-frontend,alphagov/digitalmarketplace-buyer-frontend,alphagov/digitalmarketplace-buyer-frontend,alphagov/digitalmarketplace-buyer-frontend
--- +++ @@ -16,7 +16,7 @@ for field, google_form_field in feedback_config['fields'].items(): form_data.setlist(google_form_field, request.form.getlist(field)) - result = requests.post(feedback_config['uri'], list(form_data.iteritems(multi=True))) + result = requests.post(feedback_config['uri'], list(form_data.items(multi=True))) if result.status_code != 200: raise ServiceUnavailable('Google forms submission problem (status %d)'.format(result.status_code)) came_from = url_parse(request.form['uri'])
7ddc4b975910bf9c77b753e8e0aeaebc45949e4e
linkatos.py
linkatos.py
#! /usr/bin/env python import os import time from slackclient import SlackClient import pyrebase import linkatos.parser as parser import linkatos.confirmation as confirmation import linkatos.printer as printer import linkatos.utils as utils import linkatos.firebase as fb # starterbot environment variables BOT_ID = os.environ.get("BOT_ID") SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN") # instantiate Slack clients slack_client = SlackClient(SLACK_BOT_TOKEN) # firebase environment variables FB_API_KEY = os.environ.get("FB_API_KEY") FB_USER = os.environ.get("FB_USER") FB_PASS = os.environ.get("FB_PASS") # initialise firebase project_name = 'coses-acbe6' firebase = fb.initialise(FB_API_KEY, project_name) # Main if __name__ == '__main__': READ_WEBSOCKET_DELAY = 1 # 1 second delay between reading from firehose # verify linkatos connection if slack_client.rtm_connect(): expecting_confirmation = False url = None while True: (expecting_confirmation, url) = do.keep_wanted_urls(expecting_confirmation, url) else: print("Connection failed. Invalid Slack token or bot ID?")
#! /usr/bin/env python import os import time from slackclient import SlackClient import pyrebase import linkatos.firebase as fb # starterbot environment variables BOT_ID = os.environ.get("BOT_ID") SLACK_BOT_TOKEN = os.environ.get("SLACK_BOT_TOKEN") # instantiate Slack clients slack_client = SlackClient(SLACK_BOT_TOKEN) # firebase environment variables FB_API_KEY = os.environ.get("FB_API_KEY") FB_USER = os.environ.get("FB_USER") FB_PASS = os.environ.get("FB_PASS") # initialise firebase project_name = 'coses-acbe6' firebase = fb.initialise(FB_API_KEY, project_name) # Main if __name__ == '__main__': READ_WEBSOCKET_DELAY = 1 # 1 second delay between reading from firehose # verify linkatos connection if slack_client.rtm_connect(): expecting_confirmation = False url = None while True: (expecting_confirmation, url) = do.keep_wanted_urls(expecting_confirmation, url) else: print("Connection failed. Invalid Slack token or bot ID?")
Remove old imports from main
refactor: Remove old imports from main
Python
mit
iwi/linkatos,iwi/linkatos
--- +++ @@ -3,10 +3,6 @@ import time from slackclient import SlackClient import pyrebase -import linkatos.parser as parser -import linkatos.confirmation as confirmation -import linkatos.printer as printer -import linkatos.utils as utils import linkatos.firebase as fb # starterbot environment variables
d5cd1eddf1ecf0c463a90d0e69413aadd311977a
lots/urls.py
lots/urls.py
from django.conf.urls import patterns, include, url from django.conf import settings from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: url(r'^$', 'lots_client.views.home', name='home'), url(r'^status/$', 'lots_client.views.status', name='status'), url(r'^apply/$', 'lots_client.views.apply', name='apply'), url(r'^apply-confirm/(?P<tracking_id>\S+)/$', 'lots_client.views.apply_confirm', name='apply_confirm'), url(r'^faq/$', 'lots_client.views.faq', name='faq'), url(r'^about/$', 'lots_client.views.about', name='about'), url(r'^lots-admin/$', 'lots_admin.views.lots_admin', name='lots_admin'), url(r'^lots-admin-map/$', 'lots_admin.views.lots_admin_map', name='lots_admin_map'), url(r'^csv-dump/$', 'lots_admin.views.csv_dump', name='csv_dump'), url(r'^lots-login/$', 'lots_admin.views.lots_login', name='lots_login'), url(r'^logout/$', 'lots_admin.views.lots_logout', name='logout'), url(r'^django-admin/', include(admin.site.urls)), ) urlpatterns += patterns('', url(r'^media/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': settings.MEDIA_ROOT, }), url(r'^static/(?P<path>.*)$', 'django.views.static.serve', { 'document_root': settings.STATIC_ROOT, }),)
from django.conf.urls import patterns, include, url from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: url(r'^$', 'lots_client.views.home', name='home'), url(r'^status/$', 'lots_client.views.status', name='status'), url(r'^apply/$', 'lots_client.views.apply', name='apply'), url(r'^apply-confirm/(?P<tracking_id>\S+)/$', 'lots_client.views.apply_confirm', name='apply_confirm'), url(r'^faq/$', 'lots_client.views.faq', name='faq'), url(r'^about/$', 'lots_client.views.about', name='about'), url(r'^lots-admin/$', 'lots_admin.views.lots_admin', name='lots_admin'), url(r'^lots-admin-map/$', 'lots_admin.views.lots_admin_map', name='lots_admin_map'), url(r'^csv-dump/$', 'lots_admin.views.csv_dump', name='csv_dump'), url(r'^lots-login/$', 'lots_admin.views.lots_login', name='lots_login'), url(r'^logout/$', 'lots_admin.views.lots_logout', name='logout'), url(r'^django-admin/', include(admin.site.urls)), )
Revert "Picture access from admin console"
Revert "Picture access from admin console" This reverts commit 324fa160fb629f6c4537ca15212c0822e8ac436d.
Python
mit
opencleveland/large-lots,skorasaurus/large-lots,opencleveland/large-lots,skorasaurus/large-lots,skorasaurus/large-lots,skorasaurus/large-lots,opencleveland/large-lots,opencleveland/large-lots
--- +++ @@ -1,5 +1,4 @@ from django.conf.urls import patterns, include, url -from django.conf import settings from django.contrib import admin admin.autodiscover() @@ -17,13 +16,6 @@ url(r'^csv-dump/$', 'lots_admin.views.csv_dump', name='csv_dump'), url(r'^lots-login/$', 'lots_admin.views.lots_login', name='lots_login'), url(r'^logout/$', 'lots_admin.views.lots_logout', name='logout'), + url(r'^django-admin/', include(admin.site.urls)), ) - -urlpatterns += patterns('', - url(r'^media/(?P<path>.*)$', 'django.views.static.serve', { - 'document_root': settings.MEDIA_ROOT, - }), - url(r'^static/(?P<path>.*)$', 'django.views.static.serve', { - 'document_root': settings.STATIC_ROOT, - }),)
418b65554d86f6fea33d0656ef2a98cb32607fd9
src/dicomweb_client/__init__.py
src/dicomweb_client/__init__.py
__version__ = '0.21.0rc' from dicomweb_client.api import DICOMwebClient
__version__ = '0.21.0' from dicomweb_client.api import DICOMwebClient
Increase package version for release
Increase package version for release
Python
mit
MGHComputationalPathology/dicomweb-client
--- +++ @@ -1,4 +1,4 @@ -__version__ = '0.21.0rc' +__version__ = '0.21.0' from dicomweb_client.api import DICOMwebClient
88a31ebcd7b65f9282bb0d0a19ad299c1ad431ec
spectral_cube/__init__.py
spectral_cube/__init__.py
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This is an Astropy affiliated package. """ # Affiliated packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- from ._astropy_init import * # ---------------------------------------------------------------------------- if not _ASTROPY_SETUP_: from .spectral_cube import SpectralCube, VaryingResolutionSpectralCube from .stokes_spectral_cube import StokesSpectralCube from .masks import *
# Licensed under a 3-clause BSD style license - see LICENSE.rst """ This is an Astropy affiliated package. """ # Affiliated packages may add whatever they like to this file, but # should keep this content at the top. # ---------------------------------------------------------------------------- from ._astropy_init import * # ---------------------------------------------------------------------------- if not _ASTROPY_SETUP_: from .spectral_cube import SpectralCube, VaryingResolutionSpectralCube from .stokes_spectral_cube import StokesSpectralCube from .masks import * from .lower_dimensional_structures import Projection
Make Projection importable from the top level of the package
Make Projection importable from the top level of the package
Python
bsd-3-clause
e-koch/spectral-cube,jzuhone/spectral-cube,radio-astro-tools/spectral-cube,keflavich/spectral-cube,low-sky/spectral-cube
--- +++ @@ -13,4 +13,5 @@ from .spectral_cube import SpectralCube, VaryingResolutionSpectralCube from .stokes_spectral_cube import StokesSpectralCube from .masks import * + from .lower_dimensional_structures import Projection
26749bd6bd36c4cd930e60c1eb2d0460fd16506e
CodeFights/knapsackLight.py
CodeFights/knapsackLight.py
#!/usr/local/bin/python # Code Fights Knapsack Problem def knapsackLight(value1, weight1, value2, weight2, maxW): if weight1 + weight2 <= maxW: return value1 + value2 else: return max([v for v, w in zip((value1, value2), (weight1, weight2)) if w <= maxW] + [0]) def main(): tests = [ [10, 5, 6, 4, 8, 10], [] ] for t in tests: res = knapsackLight(t[0], t[1], t[2], t[3], t[4]) ans = t[5] if ans == res: print("PASSED: knapsackLight({}, {}, {}, {}, {}) returned {}" .format(t[0], t[1], t[2], t[3], t[4], res)) else: print(("FAILED: knapsackLight({}, {}, {}, {}, {}) returned {}," "answer: {}") .format(t[0], t[1], t[2], t[3], t[4], res, ans)) if __name__ == '__main__': main()
#!/usr/local/bin/python # Code Fights Knapsack Problem def knapsackLight(value1, weight1, value2, weight2, maxW): if weight1 + weight2 <= maxW: return value1 + value2 else: return max([v for v, w in zip((value1, value2), (weight1, weight2)) if w <= maxW] + [0]) def main(): tests = [ [10, 5, 6, 4, 8, 10], [10, 5, 6, 4, 9, 16], [5, 3, 7, 4, 6, 7], [10, 2, 11, 3, 1, 0], [] ] for t in tests: res = knapsackLight(t[0], t[1], t[2], t[3], t[4]) ans = t[5] if ans == res: print("PASSED: knapsackLight({}, {}, {}, {}, {}) returned {}" .format(t[0], t[1], t[2], t[3], t[4], res)) else: print(("FAILED: knapsackLight({}, {}, {}, {}, {}) returned {}," "answer: {}") .format(t[0], t[1], t[2], t[3], t[4], res, ans)) if __name__ == '__main__': main()
Add half tests to knapsack light problem
Add half tests to knapsack light problem
Python
mit
HKuz/Test_Code
--- +++ @@ -13,6 +13,9 @@ def main(): tests = [ [10, 5, 6, 4, 8, 10], + [10, 5, 6, 4, 9, 16], + [5, 3, 7, 4, 6, 7], + [10, 2, 11, 3, 1, 0], [] ]
60290b0ae96f144cc3b5672a47596355fe117ba7
tests/test_project/settings.py
tests/test_project/settings.py
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'tests.db', }, } INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.admin', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.contenttypes', 'django.contrib.staticfiles', 'django_easyfilters', 'test_app', ] TEMPLATE_CONTEXT_PROCESSORS = [ "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.core.context_processors.tz", "django.contrib.messages.context_processors.messages", "django.core.context_processors.request", ] ROOT_URLCONF = 'test_app.urls' DEBUG = True SITE_ID = 1 STATIC_URL = '/static/' SECRET_KEY = 'x'
DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': 'tests.db', }, } INSTALLED_APPS = [ 'django.contrib.auth', 'django.contrib.admin', 'django.contrib.sessions', 'django.contrib.sites', 'django.contrib.contenttypes', 'django.contrib.staticfiles', 'django_easyfilters', 'test_app', ] TEMPLATE_CONTEXT_PROCESSORS = [ "django.contrib.auth.context_processors.auth", "django.core.context_processors.debug", "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", "django.contrib.messages.context_processors.messages", "django.core.context_processors.request", ] ROOT_URLCONF = 'test_app.urls' DEBUG = True SITE_ID = 1 STATIC_URL = '/static/' SECRET_KEY = 'x'
Remove tz context processor (not available in 1.3)
Remove tz context processor (not available in 1.3)
Python
mit
ionelmc/django-easyfilters,ionelmc/django-easyfilters
--- +++ @@ -22,7 +22,6 @@ "django.core.context_processors.i18n", "django.core.context_processors.media", "django.core.context_processors.static", - "django.core.context_processors.tz", "django.contrib.messages.context_processors.messages", "django.core.context_processors.request", ]
a8d2ede0a38188670f6921bd9c2f08ee073b0cdd
test/test_configuration.py
test/test_configuration.py
from __future__ import with_statement import os.path import tempfile from nose.tools import * from behave import configuration # one entry of each kind handled TEST_CONFIG='''[behave] outfile=/tmp/spam paths = /absolute/path relative/path tags = @foo,~@bar @zap format=pretty tag-counter stdout_capture=no bogus=spam ''' class TestConfiguration(object): def test_read_file(self): tn = tempfile.mktemp() with open(tn, 'w') as f: f.write(TEST_CONFIG) d = configuration.read_configuration(tn) eq_(d['outfile'], '/tmp/spam') eq_(d['paths'], [ '/absolute/path', os.path.normpath(os.path.join(os.path.dirname(tn), 'relative/path')), ]) eq_(d['format'], ['pretty', 'tag-counter']) eq_(d['tags'], ['@foo,~@bar', '@zap']) eq_(d['stdout_capture'], False) ok_('bogus' not in d)
from __future__ import with_statement import os.path import tempfile from nose.tools import * from behave import configuration # one entry of each kind handled TEST_CONFIG='''[behave] outfile=/tmp/spam paths = /absolute/path relative/path tags = @foo,~@bar @zap format=pretty tag-counter stdout_capture=no bogus=spam ''' class TestConfiguration(object): def test_read_file(self): tn = tempfile.mktemp() with open(tn, 'w') as f: f.write(TEST_CONFIG) d = configuration.read_configuration(tn) eq_(d['outfile'], '/tmp/spam') eq_(d['paths'], [ os.path.normpath('/absolute/path'), # -- WINDOWS-REQUIRES: normpath os.path.normpath(os.path.join(os.path.dirname(tn), 'relative/path')), ]) eq_(d['format'], ['pretty', 'tag-counter']) eq_(d['tags'], ['@foo,~@bar', '@zap']) eq_(d['stdout_capture'], False) ok_('bogus' not in d)
FIX test for Windows platform.
FIX test for Windows platform.
Python
bsd-2-clause
allanlewis/behave,allanlewis/behave,Gimpneek/behave,vrutkovs/behave,metaperl/behave,kymbert/behave,jenisys/behave,Abdoctor/behave,kymbert/behave,benthomasson/behave,mzcity123/behave,joshal/behave,charleswhchan/behave,joshal/behave,hugeinc/behave-parallel,benthomasson/behave,spacediver/behave,connorsml/behave,KevinOrtman/behave,Gimpneek/behave,Abdoctor/behave,Gimpneek/behave,metaperl/behave,jenisys/behave,mzcity123/behave,spacediver/behave,connorsml/behave,charleswhchan/behave,vrutkovs/behave,KevinOrtman/behave
--- +++ @@ -27,7 +27,7 @@ d = configuration.read_configuration(tn) eq_(d['outfile'], '/tmp/spam') eq_(d['paths'], [ - '/absolute/path', + os.path.normpath('/absolute/path'), # -- WINDOWS-REQUIRES: normpath os.path.normpath(os.path.join(os.path.dirname(tn), 'relative/path')), ]) eq_(d['format'], ['pretty', 'tag-counter'])
6a4046aafe43930c202e2f18a55b1cd8517d95f9
testanalyzer/javaanalyzer.py
testanalyzer/javaanalyzer.py
import re from fileanalyzer import FileAnalyzer class JavaAnalyzer(FileAnalyzer): def get_class_count(self, content): return len( re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_]+ *\n*\{", content)) # TODO: Accept angle brackets and decline "else if" def get_function_count(self, content): return len( re.findall( "[a-zA-Z ]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\] \n]*\)[a-zA-Z \n]*\{", content))
import re from fileanalyzer import FileAnalyzer class JavaAnalyzer(FileAnalyzer): def get_class_count(self, content): return len( re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_<>, ]+\n*\{", content)) def get_function_count(self, content): matches = re.findall( "[a-zA-Z <>]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\]<>\?\. \n]*\)[a-zA-Z \n]*\{", content) matches = [ m for m in matches if "if " not in m.strip() and "if(" not in m.strip() ] return len(matches)
Fix regex to match generics
Fix regex to match generics
Python
mpl-2.0
CheriPai/TestAnalyzer,CheriPai/TestAnalyzer,CheriPai/TestAnalyzer
--- +++ @@ -5,11 +5,14 @@ class JavaAnalyzer(FileAnalyzer): def get_class_count(self, content): return len( - re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_]+ *\n*\{", content)) + re.findall("[a-zA-Z ]*class +[a-zA-Z0-9_<>, ]+\n*\{", content)) - # TODO: Accept angle brackets and decline "else if" def get_function_count(self, content): - return len( - re.findall( - "[a-zA-Z ]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\] \n]*\)[a-zA-Z \n]*\{", - content)) + matches = re.findall( + "[a-zA-Z <>]+ +[a-zA-Z0-9_]+ *\n*\([a-zA-Z0-9_,\[\]<>\?\. \n]*\)[a-zA-Z \n]*\{", + content) + matches = [ + m for m in matches + if "if " not in m.strip() and "if(" not in m.strip() + ] + return len(matches)
3d1f4a241363d2acff056798e6cb459db1acfb1b
tests/server/handlers/test_render.py
tests/server/handlers/test_render.py
import mfr import json from tests import utils from tornado import testing class TestRenderHandler(utils.HandlerTestCase): @testing.gen_test def test_options_skips_prepare(self): # Would crash b/c lack of mocks yield self.http_client.fetch( self.get_url('/render'), method='OPTIONS' )
Add a small test for renderer
Add a small test for renderer
Python
apache-2.0
AddisonSchiller/modular-file-renderer,haoyuchen1992/modular-file-renderer,TomBaxter/modular-file-renderer,Johnetordoff/modular-file-renderer,TomBaxter/modular-file-renderer,rdhyee/modular-file-renderer,AddisonSchiller/modular-file-renderer,haoyuchen1992/modular-file-renderer,felliott/modular-file-renderer,Johnetordoff/modular-file-renderer,Johnetordoff/modular-file-renderer,felliott/modular-file-renderer,rdhyee/modular-file-renderer,felliott/modular-file-renderer,CenterForOpenScience/modular-file-renderer,TomBaxter/modular-file-renderer,rdhyee/modular-file-renderer,TomBaxter/modular-file-renderer,Johnetordoff/modular-file-renderer,CenterForOpenScience/modular-file-renderer,CenterForOpenScience/modular-file-renderer,CenterForOpenScience/modular-file-renderer,haoyuchen1992/modular-file-renderer,haoyuchen1992/modular-file-renderer,AddisonSchiller/modular-file-renderer,rdhyee/modular-file-renderer,felliott/modular-file-renderer,AddisonSchiller/modular-file-renderer
--- +++ @@ -0,0 +1,15 @@ +import mfr +import json +from tests import utils +from tornado import testing + + +class TestRenderHandler(utils.HandlerTestCase): + + @testing.gen_test + def test_options_skips_prepare(self): + # Would crash b/c lack of mocks + yield self.http_client.fetch( + self.get_url('/render'), + method='OPTIONS' + )
ea1c62ae3f13d47ee820eae31a2e284e3d66b6ab
libPiLite.py
libPiLite.py
#!/usr/bin/env python def createBlankGrid(row,column): blankgrid = [[0 for x in range(column)] for y in range(row)] return blankgrid def getHeight(grid): return len(grid) def getWidth(grid): return len(grid[0]) def printGrid(grid): numRow = len(grid) for i in range(0,numRow): row = grid[i] rowstr = '' for j in row: rowstr += str(j)+' ' print(rowstr) def serializeGrid(grid): numRow = len(grid) numCol = len(grid[0]) gridstr = '' for j in range(0,numCol): for i in range(0,numRow): gridstr += str(grid[i][j]) return gridstr
#!/usr/bin/env python def createBlankGrid(row,column): blankgrid = [[0 for x in range(column)] for y in range(row)] return blankgrid def getHeight(grid): return len(grid) def getWidth(grid): return len(grid[0]) def printGrid(grid): numRow = len(grid) for i in range(0,numRow): row = grid[i] rowstr = '' for j in row: rowstr += str(j)+' ' print(rowstr) def serializeGrid(grid): numRow = len(grid) numCol = len(grid[0]) gridstr = '' for j in range(0,numCol): for i in range(0,numRow): gridstr += str(grid[i][j]) return gridstr def setGrid(grid, setlist, rowoffset, coloffset): for entry in setlist: grid[entry[0]+rowoffset][entry[1]+coloffset] = 1 return grid def resetGrid(grid, setlist, rowoffset, coloffset): for entry in setlist: grid[entry[0]+rowoffset][entry[1]+coloffset] = 0 return grid
Add setGrid and resetGrid functions
Add setGrid and resetGrid functions
Python
mit
rorasa/RPiClockArray
--- +++ @@ -28,4 +28,13 @@ for i in range(0,numRow): gridstr += str(grid[i][j]) return gridstr - + +def setGrid(grid, setlist, rowoffset, coloffset): + for entry in setlist: + grid[entry[0]+rowoffset][entry[1]+coloffset] = 1 + return grid + +def resetGrid(grid, setlist, rowoffset, coloffset): + for entry in setlist: + grid[entry[0]+rowoffset][entry[1]+coloffset] = 0 + return grid
e0b3b767ccb7fc601eb7b40d336f94d75f8aa43c
2016/python/aoc_2016_03.py
2016/python/aoc_2016_03.py
from __future__ import annotations from typing import List, Tuple from aoc_common import load_puzzle_input, report_solution def parse_horizontal(string: str) -> List[Tuple[int, int, int]]: """Parse the instruction lines into sorted triples of side lengths.""" sorted_sides = [ sorted(int(x) for x in line.split()) for line in string.splitlines() ] triples = [(sides[0], sides[1], sides[2]) for sides in sorted_sides] return triples def filter_valid_triangles( triples: List[Tuple[int, int, int]] ) -> List[Tuple[int, int, int]]: return [triple for triple in triples if triple[0] + triple[1] > triple[2]] if __name__ == "__main__": horizontal_triples = parse_horizontal(load_puzzle_input(day=3)) valid_horizontal = filter_valid_triangles(horizontal_triples) report_solution( puzzle_title="Day 3: Squares With Three Sides", part_one_solution=len(valid_horizontal), )
from __future__ import annotations from typing import List, Tuple from aoc_common import load_puzzle_input, report_solution def parse_horizontal(string: str) -> List[Tuple[int, int, int]]: """Parse the instruction lines into triples of side lengths.""" sides = [[int(x) for x in line.split()] for line in string.splitlines()] return [(s[0], s[1], s[2]) for s in sides] def filter_valid_triangles( triples: List[Tuple[int, int, int]] ) -> List[Tuple[int, int, int]]: triples = sort_sides(triples) return [triple for triple in triples if triple[0] + triple[1] > triple[2]] def sort_sides(triples: List[Tuple[int, int, int]]) -> List[Tuple[int, int, int]]: return [(t[0], t[1], t[2]) for t in [sorted(sides) for sides in triples]] if __name__ == "__main__": horizontal_triples = parse_horizontal(load_puzzle_input(day=3)) valid_horizontal = filter_valid_triangles(horizontal_triples) report_solution( puzzle_title="Day 3: Squares With Three Sides", part_one_solution=len(valid_horizontal), )
Sort triples in separate step
2016-03.py: Sort triples in separate step
Python
mit
robjwells/adventofcode-solutions,robjwells/adventofcode-solutions,robjwells/adventofcode-solutions,robjwells/adventofcode-solutions,robjwells/adventofcode-solutions,robjwells/adventofcode-solutions
--- +++ @@ -6,18 +6,20 @@ def parse_horizontal(string: str) -> List[Tuple[int, int, int]]: - """Parse the instruction lines into sorted triples of side lengths.""" - sorted_sides = [ - sorted(int(x) for x in line.split()) for line in string.splitlines() - ] - triples = [(sides[0], sides[1], sides[2]) for sides in sorted_sides] - return triples + """Parse the instruction lines into triples of side lengths.""" + sides = [[int(x) for x in line.split()] for line in string.splitlines()] + return [(s[0], s[1], s[2]) for s in sides] def filter_valid_triangles( triples: List[Tuple[int, int, int]] ) -> List[Tuple[int, int, int]]: + triples = sort_sides(triples) return [triple for triple in triples if triple[0] + triple[1] > triple[2]] + + +def sort_sides(triples: List[Tuple[int, int, int]]) -> List[Tuple[int, int, int]]: + return [(t[0], t[1], t[2]) for t in [sorted(sides) for sides in triples]] if __name__ == "__main__":
28fe69ab1bb9362a1ee105821ec4631b574417d3
tools/perf_expectations/PRESUBMIT.py
tools/perf_expectations/PRESUBMIT.py
#!/usr/bin/python # Copyright (c) 2009 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. """Presubmit script for perf_expectations. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for details on the presubmit API built into gcl. """ UNIT_TESTS = [ 'tests.perf_expectations_unittest', ] PERF_EXPECTATIONS = 'perf_expectations.json' def CheckChangeOnUpload(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): if PERF_EXPECTATIONS == input_api.os_path.basename(path): run_tests = True output = [] if run_tests: output.extend(input_api.canned_checks.RunPythonUnitTests(input_api, output_api, UNIT_TESTS)) return output def CheckChangeOnCommit(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): if PERF_EXPECTATIONS == input_api.os_path.basename(path): run_tests = True output = [] if run_tests: output.extend(input_api.canned_checks.RunPythonUnitTests(input_api, output_api, UNIT_TESTS)) output.extend(input_api.canned_checks.CheckDoNotSubmit(input_api, output_api)) return output
#!/usr/bin/python # Copyright (c) 2009 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. """Presubmit script for perf_expectations. See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for details on the presubmit API built into gcl. """ UNIT_TESTS = [ 'tests.perf_expectations_unittest', ] PERF_EXPECTATIONS = 'tools/perf_expectations/perf_expectations.json' def CheckChangeOnUpload(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): if PERF_EXPECTATIONS == path: run_tests = True output = [] if run_tests: output.extend(input_api.canned_checks.RunPythonUnitTests(input_api, output_api, UNIT_TESTS)) return output def CheckChangeOnCommit(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): if PERF_EXPECTATIONS == path: run_tests = True output = [] if run_tests: output.extend(input_api.canned_checks.RunPythonUnitTests(input_api, output_api, UNIT_TESTS)) output.extend(input_api.canned_checks.CheckDoNotSubmit(input_api, output_api)) return output
Use full pathname to perf_expectations in test.
Use full pathname to perf_expectations in test. BUG=none TEST=none Review URL: http://codereview.chromium.org/266055 git-svn-id: de016e52bd170d2d4f2344f9bf92d50478b649e0@28770 0039d316-1c4b-4281-b951-d872f2087c98
Python
bsd-3-clause
littlstar/chromium.src,hgl888/chromium-crosswalk-efl,Jonekee/chromium.src,keishi/chromium,markYoungH/chromium.src,Just-D/chromium-1,chuan9/chromium-crosswalk,Chilledheart/chromium,timopulkkinen/BubbleFish,keishi/chromium,pozdnyakov/chromium-crosswalk,mogoweb/chromium-crosswalk,ltilve/chromium,pozdnyakov/chromium-crosswalk,jaruba/chromium.src,hujiajie/pa-chromium,rogerwang/chromium,nacl-webkit/chrome_deps,Just-D/chromium-1,junmin-zhu/chromium-rivertrail,krieger-od/nwjs_chromium.src,junmin-zhu/chromium-rivertrail,bright-sparks/chromium-spacewalk,hgl888/chromium-crosswalk,M4sse/chromium.src,ChromiumWebApps/chromium,axinging/chromium-crosswalk,ChromiumWebApps/chromium,jaruba/chromium.src,Fireblend/chromium-crosswalk,ondra-novak/chromium.src,ChromiumWebApps/chromium,krieger-od/nwjs_chromium.src,nacl-webkit/chrome_deps,TheTypoMaster/chromium-crosswalk,ltilve/chromium,krieger-od/nwjs_chromium.src,dushu1203/chromium.src,timopulkkinen/BubbleFish,mogoweb/chromium-crosswalk,bright-sparks/chromium-spacewalk,krieger-od/nwjs_chromium.src,jaruba/chromium.src,pozdnyakov/chromium-crosswalk,ltilve/chromium,ltilve/chromium,Jonekee/chromium.src,zcbenz/cefode-chromium,hgl888/chromium-crosswalk,Fireblend/chromium-crosswalk,dushu1203/chromium.src,dushu1203/chromium.src,zcbenz/cefode-chromium,markYoungH/chromium.src,rogerwang/chromium,chuan9/chromium-crosswalk,Fireblend/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,hgl888/chromium-crosswalk,jaruba/chromium.src,mogoweb/chromium-crosswalk,junmin-zhu/chromium-rivertrail,anirudhSK/chromium,axinging/chromium-crosswalk,crosswalk-project/chromium-crosswalk-efl,junmin-zhu/chromium-rivertrail,Just-D/chromium-1,pozdnyakov/chromium-crosswalk,hgl888/chromium-crosswalk,hujiajie/pa-chromium,fujunwei/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,hgl888/chromium-crosswalk-efl,M4sse/chromium.src,timopulkkinen/BubbleFish,PeterWangIntel/chromium-crosswalk,anirudhSK/chromium,hujiajie/pa-chromium,ChromiumWebApps/chromium,hgl888/chromium-crosswalk-efl,ChromiumWebApps/chromium,mogoweb/chromium-crosswalk,keishi/chromium,markYoungH/chromium.src,M4sse/chromium.src,Jonekee/chromium.src,littlstar/chromium.src,Chilledheart/chromium,patrickm/chromium.src,zcbenz/cefode-chromium,hgl888/chromium-crosswalk,junmin-zhu/chromium-rivertrail,krieger-od/nwjs_chromium.src,dednal/chromium.src,ChromiumWebApps/chromium,dushu1203/chromium.src,fujunwei/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,anirudhSK/chromium,pozdnyakov/chromium-crosswalk,hujiajie/pa-chromium,fujunwei/chromium-crosswalk,M4sse/chromium.src,littlstar/chromium.src,robclark/chromium,anirudhSK/chromium,hujiajie/pa-chromium,jaruba/chromium.src,markYoungH/chromium.src,anirudhSK/chromium,zcbenz/cefode-chromium,nacl-webkit/chrome_deps,fujunwei/chromium-crosswalk,timopulkkinen/BubbleFish,Jonekee/chromium.src,ondra-novak/chromium.src,rogerwang/chromium,Jonekee/chromium.src,Chilledheart/chromium,M4sse/chromium.src,hgl888/chromium-crosswalk-efl,ltilve/chromium,TheTypoMaster/chromium-crosswalk,zcbenz/cefode-chromium,bright-sparks/chromium-spacewalk,littlstar/chromium.src,Pluto-tv/chromium-crosswalk,fujunwei/chromium-crosswalk,zcbenz/cefode-chromium,robclark/chromium,M4sse/chromium.src,crosswalk-project/chromium-crosswalk-efl,littlstar/chromium.src,zcbenz/cefode-chromium,nacl-webkit/chrome_deps,keishi/chromium,junmin-zhu/chromium-rivertrail,robclark/chromium,Fireblend/chromium-crosswalk,dednal/chromium.src,patrickm/chromium.src,Chilledheart/chromium,nacl-webkit/chrome_deps,nacl-webkit/chrome_deps,nacl-webkit/chrome_deps,robclark/chromium,hgl888/chromium-crosswalk,patrickm/chromium.src,fujunwei/chromium-crosswalk,patrickm/chromium.src,dednal/chromium.src,fujunwei/chromium-crosswalk,axinging/chromium-crosswalk,M4sse/chromium.src,hgl888/chromium-crosswalk-efl,chuan9/chromium-crosswalk,rogerwang/chromium,mogoweb/chromium-crosswalk,nacl-webkit/chrome_deps,ondra-novak/chromium.src,robclark/chromium,ondra-novak/chromium.src,dednal/chromium.src,junmin-zhu/chromium-rivertrail,mogoweb/chromium-crosswalk,mogoweb/chromium-crosswalk,jaruba/chromium.src,PeterWangIntel/chromium-crosswalk,Chilledheart/chromium,ltilve/chromium,littlstar/chromium.src,Just-D/chromium-1,crosswalk-project/chromium-crosswalk-efl,timopulkkinen/BubbleFish,patrickm/chromium.src,dednal/chromium.src,anirudhSK/chromium,junmin-zhu/chromium-rivertrail,Chilledheart/chromium,Fireblend/chromium-crosswalk,zcbenz/cefode-chromium,anirudhSK/chromium,dednal/chromium.src,ondra-novak/chromium.src,chuan9/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,patrickm/chromium.src,nacl-webkit/chrome_deps,hgl888/chromium-crosswalk,dednal/chromium.src,crosswalk-project/chromium-crosswalk-efl,M4sse/chromium.src,krieger-od/nwjs_chromium.src,dushu1203/chromium.src,robclark/chromium,rogerwang/chromium,M4sse/chromium.src,crosswalk-project/chromium-crosswalk-efl,hujiajie/pa-chromium,bright-sparks/chromium-spacewalk,timopulkkinen/BubbleFish,dednal/chromium.src,jaruba/chromium.src,axinging/chromium-crosswalk,bright-sparks/chromium-spacewalk,ondra-novak/chromium.src,ChromiumWebApps/chromium,chuan9/chromium-crosswalk,pozdnyakov/chromium-crosswalk,timopulkkinen/BubbleFish,pozdnyakov/chromium-crosswalk,mogoweb/chromium-crosswalk,robclark/chromium,keishi/chromium,crosswalk-project/chromium-crosswalk-efl,bright-sparks/chromium-spacewalk,ChromiumWebApps/chromium,robclark/chromium,zcbenz/cefode-chromium,ondra-novak/chromium.src,Jonekee/chromium.src,anirudhSK/chromium,dednal/chromium.src,TheTypoMaster/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,dednal/chromium.src,anirudhSK/chromium,Just-D/chromium-1,junmin-zhu/chromium-rivertrail,dushu1203/chromium.src,keishi/chromium,mogoweb/chromium-crosswalk,timopulkkinen/BubbleFish,Pluto-tv/chromium-crosswalk,bright-sparks/chromium-spacewalk,Jonekee/chromium.src,zcbenz/cefode-chromium,bright-sparks/chromium-spacewalk,chuan9/chromium-crosswalk,axinging/chromium-crosswalk,axinging/chromium-crosswalk,keishi/chromium,littlstar/chromium.src,ChromiumWebApps/chromium,M4sse/chromium.src,anirudhSK/chromium,timopulkkinen/BubbleFish,krieger-od/nwjs_chromium.src,pozdnyakov/chromium-crosswalk,rogerwang/chromium,Pluto-tv/chromium-crosswalk,markYoungH/chromium.src,rogerwang/chromium,hujiajie/pa-chromium,axinging/chromium-crosswalk,fujunwei/chromium-crosswalk,chuan9/chromium-crosswalk,krieger-od/nwjs_chromium.src,dushu1203/chromium.src,hujiajie/pa-chromium,axinging/chromium-crosswalk,Pluto-tv/chromium-crosswalk,rogerwang/chromium,PeterWangIntel/chromium-crosswalk,pozdnyakov/chromium-crosswalk,keishi/chromium,mohamed--abdel-maksoud/chromium.src,Jonekee/chromium.src,hgl888/chromium-crosswalk,keishi/chromium,Just-D/chromium-1,PeterWangIntel/chromium-crosswalk,fujunwei/chromium-crosswalk,markYoungH/chromium.src,ltilve/chromium,jaruba/chromium.src,Chilledheart/chromium,mohamed--abdel-maksoud/chromium.src,anirudhSK/chromium,rogerwang/chromium,Fireblend/chromium-crosswalk,Pluto-tv/chromium-crosswalk,ondra-novak/chromium.src,nacl-webkit/chrome_deps,timopulkkinen/BubbleFish,markYoungH/chromium.src,hujiajie/pa-chromium,mohamed--abdel-maksoud/chromium.src,ltilve/chromium,dushu1203/chromium.src,ChromiumWebApps/chromium,Fireblend/chromium-crosswalk,keishi/chromium,TheTypoMaster/chromium-crosswalk,keishi/chromium,mohamed--abdel-maksoud/chromium.src,Jonekee/chromium.src,ChromiumWebApps/chromium,ChromiumWebApps/chromium,markYoungH/chromium.src,rogerwang/chromium,ltilve/chromium,krieger-od/nwjs_chromium.src,Just-D/chromium-1,patrickm/chromium.src,axinging/chromium-crosswalk,patrickm/chromium.src,jaruba/chromium.src,crosswalk-project/chromium-crosswalk-efl,ondra-novak/chromium.src,krieger-od/nwjs_chromium.src,Pluto-tv/chromium-crosswalk,timopulkkinen/BubbleFish,littlstar/chromium.src,Just-D/chromium-1,crosswalk-project/chromium-crosswalk-efl,chuan9/chromium-crosswalk,dushu1203/chromium.src,Pluto-tv/chromium-crosswalk,dednal/chromium.src,pozdnyakov/chromium-crosswalk,Pluto-tv/chromium-crosswalk,Fireblend/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,robclark/chromium,mohamed--abdel-maksoud/chromium.src,Just-D/chromium-1,jaruba/chromium.src,patrickm/chromium.src,hgl888/chromium-crosswalk-efl,TheTypoMaster/chromium-crosswalk,Chilledheart/chromium,PeterWangIntel/chromium-crosswalk,hujiajie/pa-chromium,krieger-od/nwjs_chromium.src,PeterWangIntel/chromium-crosswalk,PeterWangIntel/chromium-crosswalk,junmin-zhu/chromium-rivertrail,TheTypoMaster/chromium-crosswalk,markYoungH/chromium.src,Chilledheart/chromium,axinging/chromium-crosswalk,robclark/chromium,pozdnyakov/chromium-crosswalk,chuan9/chromium-crosswalk,Pluto-tv/chromium-crosswalk,nacl-webkit/chrome_deps,zcbenz/cefode-chromium,hgl888/chromium-crosswalk-efl,junmin-zhu/chromium-rivertrail,mogoweb/chromium-crosswalk,mohamed--abdel-maksoud/chromium.src,TheTypoMaster/chromium-crosswalk,hujiajie/pa-chromium,jaruba/chromium.src,mohamed--abdel-maksoud/chromium.src,mohamed--abdel-maksoud/chromium.src,markYoungH/chromium.src,M4sse/chromium.src,hgl888/chromium-crosswalk-efl,hgl888/chromium-crosswalk-efl,anirudhSK/chromium,Jonekee/chromium.src,markYoungH/chromium.src,Fireblend/chromium-crosswalk,hgl888/chromium-crosswalk-efl,Jonekee/chromium.src,crosswalk-project/chromium-crosswalk-efl,dushu1203/chromium.src,bright-sparks/chromium-spacewalk,dushu1203/chromium.src,hgl888/chromium-crosswalk,TheTypoMaster/chromium-crosswalk,axinging/chromium-crosswalk
--- +++ @@ -13,12 +13,12 @@ 'tests.perf_expectations_unittest', ] -PERF_EXPECTATIONS = 'perf_expectations.json' +PERF_EXPECTATIONS = 'tools/perf_expectations/perf_expectations.json' def CheckChangeOnUpload(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): - if PERF_EXPECTATIONS == input_api.os_path.basename(path): + if PERF_EXPECTATIONS == path: run_tests = True output = [] @@ -32,7 +32,7 @@ def CheckChangeOnCommit(input_api, output_api): run_tests = False for path in input_api.LocalPaths(): - if PERF_EXPECTATIONS == input_api.os_path.basename(path): + if PERF_EXPECTATIONS == path: run_tests = True output = []
8b5337878172df95400a708b096e012436f8a706
dags/main_summary.py
dags/main_summary.py
from airflow import DAG from datetime import datetime, timedelta from operators.emr_spark_operator import EMRSparkOperator from airflow.operators import BashOperator default_args = { 'owner': '[email protected]', 'depends_on_past': False, 'start_date': datetime(2016, 6, 27), 'email': ['[email protected]', '[email protected]'], 'email_on_failure': True, 'email_on_retry': True, 'retries': 2, 'retry_delay': timedelta(minutes=30), } dag = DAG('main_summary', default_args=default_args, schedule_interval='@daily') # Make sure all the data for the given day has arrived before running. t0 = BashOperator(task_id="delayed_start", bash_command="sleep 1800", dag=dag) t1 = EMRSparkOperator(task_id="main_summary", job_name="Main Summary View", execution_timeout=timedelta(hours=10), instance_count=10, env = {"date": "{{ ds_nodash }}", "bucket": "{{ task.__class__.private_output_bucket }}"}, uri="https://raw.githubusercontent.com/mozilla/telemetry-airflow/master/jobs/main_summary_view.sh", dag=dag) # Wait a little while after midnight to start for a given day. t1.set_upstream(t0)
from airflow import DAG from datetime import datetime, timedelta from operators.emr_spark_operator import EMRSparkOperator from airflow.operators import BashOperator default_args = { 'owner': '[email protected]', 'depends_on_past': False, 'start_date': datetime(2016, 6, 25), 'email': ['[email protected]', '[email protected]'], 'email_on_failure': True, 'email_on_retry': True, 'retries': 2, 'retry_delay': timedelta(minutes=30), } dag = DAG('main_summary', default_args=default_args, schedule_interval='@daily', max_active_runs=10) # Make sure all the data for the given day has arrived before running. t0 = BashOperator(task_id="delayed_start", bash_command="sleep 1800", dag=dag) t1 = EMRSparkOperator(task_id="main_summary", job_name="Main Summary View", execution_timeout=timedelta(hours=10), instance_count=10, env={"date": "{{ ds_nodash }}", "bucket": "{{ task.__class__.private_output_bucket }}"}, uri="https://raw.githubusercontent.com/mozilla/telemetry-airflow/master/jobs/main_summary_view.sh", dag=dag) # Wait a little while after midnight to start for a given day. t1.set_upstream(t0)
Prepare "Main Summary" job for backfill
Prepare "Main Summary" job for backfill Set the max number of active runs so we don't overwhelm the system, and rewind the start date by a couple of days to test that the scheduler does the right thing.
Python
mpl-2.0
opentrials/opentrials-airflow,opentrials/opentrials-airflow
--- +++ @@ -6,7 +6,7 @@ default_args = { 'owner': '[email protected]', 'depends_on_past': False, - 'start_date': datetime(2016, 6, 27), + 'start_date': datetime(2016, 6, 25), 'email': ['[email protected]', '[email protected]'], 'email_on_failure': True, 'email_on_retry': True, @@ -14,7 +14,7 @@ 'retry_delay': timedelta(minutes=30), } -dag = DAG('main_summary', default_args=default_args, schedule_interval='@daily') +dag = DAG('main_summary', default_args=default_args, schedule_interval='@daily', max_active_runs=10) # Make sure all the data for the given day has arrived before running. t0 = BashOperator(task_id="delayed_start", @@ -25,7 +25,7 @@ job_name="Main Summary View", execution_timeout=timedelta(hours=10), instance_count=10, - env = {"date": "{{ ds_nodash }}", "bucket": "{{ task.__class__.private_output_bucket }}"}, + env={"date": "{{ ds_nodash }}", "bucket": "{{ task.__class__.private_output_bucket }}"}, uri="https://raw.githubusercontent.com/mozilla/telemetry-airflow/master/jobs/main_summary_view.sh", dag=dag)
847375a5cd6cbc160c190c9fb5e9fa2b1f0cdea9
lustro/db.py
lustro/db.py
# -*- coding: utf-8 -*- from sqlalchemy import MetaData, create_engine from sqlalchemy.orm import Session from sqlalchemy.ext.automap import automap_base class DB(object): """Facade for the low level DB operations""" def __init__(self, dsn, schema=None): self.engine = create_engine(dsn) self.meta = MetaData() self.meta.reflect(bind=self.engine, schema=schema) self.base = automap_base(metadata=self.meta) self.base.prepare() def get_classes(self): return self.base.classes def get_session(self): return Session(self.engine) def get_rows(self, session, cls, modified=None): return session.query(cls).all() class Mirror(object): """API for cli mirroring operations""" def __init__(self, source, target, source_schema=None, target_schema=None): self.source = DB(source, source_schema) self.target = DB(target, target_schema) def diff(self, tables): pass def create(self, tables): pass def recreate(self, tables): pass def mirror(self, tables): pass
# -*- coding: utf-8 -*- from sqlalchemy import MetaData, create_engine from sqlalchemy.orm import Session from sqlalchemy.ext.automap import automap_base class DB(object): """Facade for the low level DB operations""" def __init__(self, dsn, schema=None): self.engine = create_engine(dsn) self.meta = MetaData() self.meta.reflect(bind=self.engine, schema=schema) self.base = automap_base(metadata=self.meta) self.base.prepare() def get_classes(self): return self.base.classes def get_session(self): return Session(self.engine) def get_rows(self, session, cls, modified=None): return session.query(cls).all() class Mirror(object): """API for cli mirroring operations""" def __init__(self, source, target, source_schema=None, target_schema=None): self.source = DB(source, source_schema) self.target = DB(target, target_schema) def diff(self, tables, modified): pass def create(self, tables): pass def recreate(self, tables): pass def mirror(self, tables): pass
Fix arguments to diff method
Fix arguments to diff method
Python
mit
ashwoods/lustro
--- +++ @@ -30,7 +30,7 @@ self.source = DB(source, source_schema) self.target = DB(target, target_schema) - def diff(self, tables): + def diff(self, tables, modified): pass def create(self, tables):