commit
stringlengths
40
40
old_file
stringlengths
4
118
new_file
stringlengths
4
118
old_contents
stringlengths
1
2.94k
new_contents
stringlengths
1
4.43k
subject
stringlengths
15
444
message
stringlengths
16
3.45k
lang
stringclasses
1 value
license
stringclasses
13 values
repos
stringlengths
5
43.2k
24c1309a9f221ec8be6a3b15dc843769f4157cf1
allauth/socialaccount/providers/twitch/views.py
allauth/socialaccount/providers/twitch/views.py
import requests from allauth.socialaccount.providers.oauth2.views import ( OAuth2Adapter, OAuth2CallbackView, OAuth2LoginView, ) from .provider import TwitchProvider class TwitchOAuth2Adapter(OAuth2Adapter): provider_id = TwitchProvider.id access_token_url = 'https://api.twitch.tv/kraken/oauth2/token' authorize_url = 'https://api.twitch.tv/kraken/oauth2/authorize' profile_url = 'https://api.twitch.tv/kraken/user' def complete_login(self, request, app, token, **kwargs): resp = requests.get( self.profile_url, params={'oauth_token': token.token, 'client_id': app.client_id}) extra_data = resp.json() return self.get_provider().sociallogin_from_response(request, extra_data) oauth2_login = OAuth2LoginView.adapter_view(TwitchOAuth2Adapter) oauth2_callback = OAuth2CallbackView.adapter_view(TwitchOAuth2Adapter)
import requests from allauth.socialaccount.providers.oauth2.client import OAuth2Error from allauth.socialaccount.providers.oauth2.views import ( OAuth2Adapter, OAuth2CallbackView, OAuth2LoginView, ) from .provider import TwitchProvider class TwitchOAuth2Adapter(OAuth2Adapter): provider_id = TwitchProvider.id access_token_url = 'https://api.twitch.tv/kraken/oauth2/token' authorize_url = 'https://api.twitch.tv/kraken/oauth2/authorize' profile_url = 'https://api.twitch.tv/kraken/user' def complete_login(self, request, app, token, **kwargs): params = {"oauth_token": token.token, "client_id": app.client_id} response = requests.get(self.profile_url, params=params) data = response.json() if response.status_code >= 400: error = data.get("error", "") message = data.get("message", "") raise OAuth2Error("Twitch API Error: %s (%s)" % (error, message)) if "_id" not in data: raise OAuth2Error("Invalid data from Twitch API: %r" % (data)) return self.get_provider().sociallogin_from_response(request, data) oauth2_login = OAuth2LoginView.adapter_view(TwitchOAuth2Adapter) oauth2_callback = OAuth2CallbackView.adapter_view(TwitchOAuth2Adapter)
Add error checking in API response
twitch: Add error checking in API response
Python
mit
rsalmaso/django-allauth,lukeburden/django-allauth,pennersr/django-allauth,AltSchool/django-allauth,pztrick/django-allauth,AltSchool/django-allauth,rsalmaso/django-allauth,bittner/django-allauth,pztrick/django-allauth,pennersr/django-allauth,lukeburden/django-allauth,lukeburden/django-allauth,pztrick/django-allauth,bittner/django-allauth,AltSchool/django-allauth,rsalmaso/django-allauth,bittner/django-allauth,pennersr/django-allauth
8d9bb10d5281fe89f693068143e45ff761200abd
01_Built-in_Types/list.py
01_Built-in_Types/list.py
#!/usr/bin/env python import sys print("argv: %d" % len(sys.argv)) # Object related test print(type(sys.argv)) print(id(sys.argv)) print(type(sys.argv) is list) if len(sys.argv) != 2: print("%s filename" % sys.argv[0]) raise SystemExit(1) file = open(sys.argv[1], "w") line = [] while True: line = sys.stdin.readline() if line == "quit\n": break file.write(line) file.close() print("\nok. start to dump %s:" % sys.argv[1]) for line in open(sys.argv[1]): print line.rstrip() file = open(sys.argv[1]) lines = file.readlines() file.close() print(lines) fval = [float(line) for line in lines] print(fval) print("len: %d" % len(fval)) for i in range(len(fval)): print i, " ", fval[i]
#!/usr/bin/env python import sys print("argv: %d" % len(sys.argv)) # Object related test # type and id are unique # ref: https://docs.python.org/2/reference/datamodel.html # mutable object: value can be changed # immutable object: value can NOT be changed after created # This means readonly # ex: string, numbers, tuple print(type(sys.argv)) print(id(sys.argv)) print(type(sys.argv) is list) if len(sys.argv) != 2: print("%s filename" % sys.argv[0]) raise SystemExit(1) file = open(sys.argv[1], "w") line = [] while True: line = sys.stdin.readline() if line == "quit\n": break file.write(line) file.close() print("\nok. start to dump %s:" % sys.argv[1]) for line in open(sys.argv[1]): print line.rstrip() file = open(sys.argv[1]) lines = file.readlines() file.close() print(lines) fval = [float(line) for line in lines] print(fval) print("len: %d" % len(fval)) for i in range(len(fval)): print i, " ", fval[i]
Add comment for object types
Add comment for object types
Python
bsd-2-clause
zzz0072/Python_Exercises,zzz0072/Python_Exercises
8386d7372f9ff8bfad651efe43504746aff19b73
app/models/rooms/rooms.py
app/models/rooms/rooms.py
from models.people.people import Staff, Fellow from models.rooms.rooms import Office, LivingSpace import random class Dojo(object): def __init__(self): self.offices = [] self.livingrooms = [] self.staff = [] self.fellows = [] self.all_rooms = [] self.all_people = [] def get_room(self, rooms): """A function to generate a list of random rooms with space. :param rooms: :return: room_name """ # a room is only available if it's capacity is not exceeded available_rooms = [room for room in rooms if len(room.occupants) < room.room_capacity] # return False if all rooms are full if len(available_rooms) < 1: return False # choose a room fro the list of available rooms. chosen_room = random.choice(available_rooms) return chosen_room.room_name def create_room(self, room_name, room_type): if room_type is 'office': if room_name not in [room.room_name for room in self.offices]: room = Office(room_name=room_name, room_type=room_type) self.offices.append(room) self.all_rooms.append(room) return 'An office called' + ' ' + room_name + ' ' + 'has been successfully created' return 'An office with that name already exists' if room_type is 'livingspace': if room_name not in [room.room_name for room in self.livingrooms]: room = LivingSpace(room_name=room_name, room_type=room_type) # add object to list( has both room_name and room_type) self.livingrooms.append(room) self.all_rooms.append(room) return 'A room called ' + room_name + ' has been successfully created!' return 'A living room with that name already exists'
import os import sys from os import path sys.path.append(path.dirname(path.dirname(path.abspath(__file__)))) class Room(object): """Models the kind of rooms available at Andela, It forms the base class Room from which OfficeSpace and LivingRoom inherit""" def __init__(self, room_name, room_type, room_capacity): """Initializes the base class Room :param room_name: A string representing the name of the room :param room_type: A string representing the type of room, whether office or residential :param room_capacity: An integer representing the amount of space per room. """ self.room_name = room_name self.room_type = room_type self.room_capacity = room_capacity self.occupants = []
Implement the Room base class
Implement the Room base class
Python
mit
Alweezy/alvin-mutisya-dojo-project
fe25e0d68647af689c4015f1728cd7dd2d48b7ee
scripts/example_parser.py
scripts/example_parser.py
# This is an example of how to parse ooniprobe reports import yaml import sys print "Opening %s" % sys.argv[1] f = open(sys.argv[1]) yamloo = yaml.safe_load_all(f) report_header = yamloo.next() print "ASN: %s" % report_header['probe_asn'] print "CC: %s" % report_header['probe_cc'] print "IP: %s" % report_header['probe_ip'] print "Start Time: %s" % report_header['start_time'] print "Test name: %s" % report_header['test_name'] print "Test version: %s" % report_header['test_version'] for report_entry in yamloo: print "Test: %s" % report_entry['test'] print "Input: %s" % report_entry['input'] print "Report: %s" % report_entry['report'] f.close()
# This is an example of how to parse ooniprobe reports import yaml import sys print "Opening %s" % sys.argv[1] f = open(sys.argv[1]) yamloo = yaml.safe_load_all(f) report_header = yamloo.next() print "ASN: %s" % report_header['probe_asn'] print "CC: %s" % report_header['probe_cc'] print "IP: %s" % report_header['probe_ip'] print "Start Time: %s" % report_header['start_time'] print "Test name: %s" % report_header['test_name'] print "Test version: %s" % report_header['test_version'] for report_entry in yamloo: print "Test: %s" % report_entry['test_name'] print "Input: %s" % report_entry['input'] print "Report: %s" % report_entry['report'] f.close()
Update parser to the changes in the report format
Update parser to the changes in the report format
Python
bsd-2-clause
0xPoly/ooni-probe,0xPoly/ooni-probe,lordappsec/ooni-probe,juga0/ooni-probe,kdmurray91/ooni-probe,juga0/ooni-probe,kdmurray91/ooni-probe,Karthikeyan-kkk/ooni-probe,lordappsec/ooni-probe,juga0/ooni-probe,Karthikeyan-kkk/ooni-probe,kdmurray91/ooni-probe,kdmurray91/ooni-probe,0xPoly/ooni-probe,lordappsec/ooni-probe,0xPoly/ooni-probe,lordappsec/ooni-probe,juga0/ooni-probe,Karthikeyan-kkk/ooni-probe,Karthikeyan-kkk/ooni-probe
df2d24757d8e12035437d152d17dc9016f1cd9df
app/__init__.py
app/__init__.py
#!/usr/bin/env python # -*- coding: utf-8 -*- """ File: __init__.py Author: huxuan <i(at)huxuan.org> Description: Initial file for app. """ from flask import Flask app = Flask(__name__) # pylint: disable=invalid-name app.config.from_object('config') # commented as for file structure, should recover later. # from app import models @app.route('/') @app.route('/hellworld') def helloworld(): """ Hello World for app. """ return 'Hello world from {}!'.format(__name__)
#!/usr/bin/env python # -*- coding: utf-8 -*- """ File: __init__.py Author: huxuan <i(at)huxuan.org> Description: Initial file for app. """ from flask import Flask from flask.ext.sqlalchemy import SQLAlchemy app = Flask(__name__) # pylint: disable=invalid-name app.config.from_object('config') # commented as for file structure, should recover later. # from app import models db = SQLAlchemy(app) @app.route('/') @app.route('/hellworld') def helloworld(): """ Hello World for app. """ return 'Hello world from {}!'.format(__name__)
Create model in config file.
Create model in config file.
Python
mit
CAPU-ENG/CAPUHome-API,huxuan/CAPUHome-API
8c2996b94cdc3210b24ebeaeb957c625629f68a5
hunting/level/encoder.py
hunting/level/encoder.py
import json import hunting.sim.entities as entities class GameObjectEncoder(json.JSONEncoder): def default(self, o): d = o.__dict__ d.pop('owner', None) if isinstance(o, entities.GameObject): d.pop('log', None) d.pop('ai', None) return d elif isinstance(o, entities.Fighter): d.pop('death_function') return d elif isinstance(o, entities.ChangeableProperty): return {k: o.__dict__[k] for k in ['property_type', 'base']} else: return d def encode_level(level): save_factions = [f for f in level.get_factions() if level.get_faction_info(f)['save'] is True] factions_to_objects = {f: level.get_objects_inside_faction(f) for f in save_factions} return json.dumps(factions_to_objects, cls=GameObjectEncoder, indent=2)
import json import hunting.sim.entities as entities class GameObjectEncoder(json.JSONEncoder): def default(self, o): d = o.__dict__ d.pop('owner', None) if isinstance(o, entities.GameObject): d.pop('log', None) d.pop('ai', None) return d elif isinstance(o, entities.Fighter): d.pop('death_function') return d elif isinstance(o, entities.ChangeableProperty): return {k: o.__dict__[k] for k in ['property_type', 'base']} else: return d def encode_level(level): save_factions = {f: level.get_faction_info(f) for f in level.get_factions() if level.get_faction_info(f)['save'] is True} for f in save_factions: save_factions[f]['objects'] = level.get_objects_inside_faction(f) output = {'log': level.log.events, 'factions': save_factions} return json.dumps(output, cls=GameObjectEncoder, indent=2)
Add log to encoding output (still fails due to objects)
Add log to encoding output (still fails due to objects)
Python
mit
MoyTW/RL_Arena_Experiment
28960dc03e5e14db94d18b968947257029f934d8
cw_draw_stairs.py
cw_draw_stairs.py
"""Codewars: Draw stairs 8 kyu URL: https://www.codewars.com/kata/draw-stairs/ Given a number n, draw stairs using the letter "I", n tall and n wide, with the tallest in the top left. For example n = 3 result in "I\n I\n I", or printed: I I I Another example, a 7-step stairs should be drawn like this: I I I I I I I """ def draw_stairs(n): stairs = [] for i in range(n): # Append (i - 1) spaces. for _ in range(i): stairs.append(' ') # Append stair I. stairs.append('I') # Append change line if not the last line. if i != n - 1: stairs.append('\n') return ''.join(stairs) def main(): # Output: "I\n I\n I" n = 3 print draw_stairs(n) # Output: "I\n I\n I\n I\n I\n I\n I\n I" n = 7 print draw_stairs(n) if __name__ == '__main__': main()
"""Codewars: Draw stairs 8 kyu URL: https://www.codewars.com/kata/draw-stairs/ Given a number n, draw stairs using the letter "I", n tall and n wide, with the tallest in the top left. For example n = 3 result in "I\n I\n I", or printed: I I I Another example, a 7-step stairs should be drawn like this: I I I I I I I """ def draw_stairs(n): """ Time complexity: O(n^2). Space complexity: O(n). """ stairs = [] for i in range(n): # Append (i - 1) spaces. stairs.append(' ' * i) # Append stair I. stairs.append('I') # Append change line if not the last line. if i != n - 1: stairs.append('\n') return ''.join(stairs) def main(): # Output: "I\n I\n I" n = 3 print draw_stairs(n) # Output: "I\n I\n I\n I\n I\n I\n I\n I" n = 7 print draw_stairs(n) if __name__ == '__main__': main()
Simplify adding spaces and add time/space complexity
Simplify adding spaces and add time/space complexity
Python
bsd-2-clause
bowen0701/algorithms_data_structures
b723cbceb896f7ca8690eaa13c38ffb20fecd0be
avocado/search_indexes.py
avocado/search_indexes.py
import warnings from haystack import indexes from avocado.conf import settings from avocado.models import DataConcept, DataField # Warn if either of the settings are set to false if not getattr(settings, 'CONCEPT_SEARCH_ENABLED', True) or \ not getattr(settings, 'FIELD_SEARCH_ENABLED', True): warnings.warn('CONCEPT_SEARCH_ENABLED and FIELD_SEARCH_ENABLED have been ' 'deprecated due to changes in Haystack 2.x API. To exclude ' 'an index from being discovered, add the path to the class ' 'to EXCLUDED_INDEXES in the appropriate ' 'HAYSTACK_CONNECTIONS entry in settings.') class DataIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) text_auto = indexes.EdgeNgramField(use_template=True) def index_queryset(self, using=None): return self.get_model().objects.published() def load_all_queryset(self): return self.index_queryset() class DataConceptIndex(DataIndex, indexes.Indexable): def get_model(self): return DataConcept class DataFieldIndex(DataIndex, indexes.Indexable): def get_model(self): return DataField
from haystack import indexes from avocado.models import DataConcept, DataField class DataIndex(indexes.SearchIndex): text = indexes.CharField(document=True, use_template=True) text_auto = indexes.EdgeNgramField(use_template=True) def index_queryset(self, using=None): return self.get_model().objects.filter(published=True, archived=False) def read_queryset(self, using=None): return self.index_queryset() def load_all_queryset(self): return self.index_queryset() class DataConceptIndex(DataIndex, indexes.Indexable): def get_model(self): return DataConcept class DataFieldIndex(DataIndex, indexes.Indexable): def get_model(self): return DataField
Change DataIndex to restrict on published and archived flags only
Change DataIndex to restrict on published and archived flags only In addition, the warnings of the deprecated settings have been removed. Fix #290 Signed-off-by: Byron Ruth <[email protected]>
Python
bsd-2-clause
murphyke/avocado,murphyke/avocado,murphyke/avocado,murphyke/avocado
c954c153525265b2b4ff0d89f0cf7f89c08a136c
settings/test_settings.py
settings/test_settings.py
# -*- coding: utf-8 -*-# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import os from .common import * # noqa DEBUG = True TEMPLATE_DEBUG = DEBUG DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(ROOT_DIR, 'test.sqlite3'), } } TEMPLATE_CONTEXT_PROCESSORS += ( "django.core.context_processors.debug", ) EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' INSTALLED_APPS += ('django_extensions',) DEVICE_VERIFICATION_CODE = 11111 # DEBUG TOOLBAR INSTALLED_APPS += ('debug_toolbar',)
# -*- coding: utf-8 -*-# -*- coding: utf-8 -*- from __future__ import absolute_import, unicode_literals import os from .common import * # noqa DEBUG = True TEMPLATE_DEBUG = DEBUG DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', 'NAME': os.path.join(ROOT_DIR, 'test.sqlite3'), } } TEMPLATE_CONTEXT_PROCESSORS += ( "django.core.context_processors.debug", ) EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend' INSTALLED_APPS += ('django_extensions',) DEVICE_VERIFICATION_CODE = 11111
Remove debug toolbar in test settings
Remove debug toolbar in test settings
Python
mit
praba230890/junction,praba230890/junction,farhaanbukhsh/junction,farhaanbukhsh/junction,pythonindia/junction,ChillarAnand/junction,pythonindia/junction,praba230890/junction,ChillarAnand/junction,pythonindia/junction,nava45/junction,nava45/junction,ChillarAnand/junction,nava45/junction,ChillarAnand/junction,praba230890/junction,farhaanbukhsh/junction,pythonindia/junction,nava45/junction,farhaanbukhsh/junction
d36a4453eb6b62f8eda4614f276fdf9ba7afb26a
tests/test_main.py
tests/test_main.py
# -*- coding:utf-8 -*- from os.path import curdir, devnull from subprocess import check_call from pytest import fixture, mark, raises from csft import __main__ as main @fixture def null(): with open(devnull, 'w') as fobj: yield fobj def test_call(null): check_call(['python', '-m', 'csft', 'csft'], stdout=null, stderr=null) @mark.parametrize('argv', [None, [], ['csft'], ]) def test_main(argv, mocker): obj = object() mocker.patch('sys.argv', ['csft']) csft2data = mocker.patch('csft.__main__.csft2data', return_value=obj) pr = mocker.patch('builtins.print') assert 0 == main.main(argv=argv) if argv: csft2data.assert_called_once_with(main._dir(argv[0])) else: csft2data.assert_called_once_with(main._dir(curdir)) pr.assert_called_once_with(obj) def test_wrong_path(capsys): with raises(SystemExit): main.main(argv=['path/is/not/a/directory']) assert capsys.readouterr() def test_show_version(capsys): try: main.main(argv=['-V']) except SystemExit as err: assert 0 == err.code from csft import __version__ assert __version__ == capsys.readouterr().out.strip()
# -*- coding:utf-8 -*- from os.path import curdir, devnull from subprocess import check_call from pytest import fixture, mark, raises from csft import __main__ as main @fixture def null(): with open(devnull, 'w') as fobj: yield fobj def test_call(null): check_call(['python', '-m', 'csft', 'csft'], stdout=null, stderr=null) @mark.parametrize('argv', [None, [], ['csft'], ]) def test_main(argv, mocker): obj = object() mocker.patch('sys.argv', ['csft']) csft2data = mocker.patch('csft.__main__.csft2data', return_value=obj) pr = mocker.patch('builtins.print') assert 0 == main.main(argv=argv) if argv: csft2data.assert_called_once_with(main._dir(argv[0])) else: csft2data.assert_called_once_with(main._dir(curdir)) pr.assert_called_once_with(obj) def test_wrong_path(capsys): with raises(SystemExit): main.main(argv=['path/is/not/a/directory']) assert capsys.readouterr() def test_show_version(capsys): try: main.main(argv=['-V']) except SystemExit as err: assert 0 == err.code from csft import __version__ out = capsys.readouterr()[0] assert __version__ == out.strip()
Fix compatible error about capsys.
Fix compatible error about capsys.
Python
mit
yanqd0/csft
87acf306addc60d7678ff980aef4b87f4225839b
theo_actual_nut.py
theo_actual_nut.py
from itertools import combinations from deuces.deuces import Card, Evaluator, Deck from nuts import nut_hand evaluator = Evaluator() deck = Deck() flop = deck.draw(3) def omaha_eval(hole, board): assert(len(hole)) == 4 ranks = [] for ph in combinations(hole, 2): thisrank = evaluator.evaluate(list(ph), board) ranks.append(thisrank) return min(ranks) def r2t(x): return evaluator.class_to_string(evaluator.get_rank_class(x)) def list_to_pretty_str(card_ints): output = " " for i in range(len(card_ints)): c = card_ints[i] if i != len(card_ints) - 1: output += Card.int_to_pretty_str(c) + "," else: output += Card.int_to_pretty_str(c) + " " return output print list_to_pretty_str(flop), "nuts = ", nut_hand(flop) for i in range(6): player = deck.draw(4) realrank = omaha_eval(player, flop) realtext = r2t(realrank) print list_to_pretty_str(player), realtext
from itertools import combinations from deuces.deuces import Card, Evaluator, Deck from nuts import nut_hand evaluator = Evaluator() deck = Deck() flop = deck.draw(3) def omaha_eval(hole, board): assert(len(hole)) == 4 ranks = [] for ph in combinations(hole, 2): thisrank = evaluator.evaluate(list(ph), board) ranks.append(thisrank) return min(ranks) def r2t(x): return evaluator.class_to_string(evaluator.get_rank_class(x)) def r2c(x): return evaluator.get_rank_class(x) def list_to_pretty_str(card_ints): output = " " for i in range(len(card_ints)): c = card_ints[i] if i != len(card_ints) - 1: output += Card.int_to_pretty_str(c) + "," else: output += Card.int_to_pretty_str(c) + " " return output print list_to_pretty_str(flop) rank_clasess= [] for i in range(6): player = deck.draw(4) realrank = omaha_eval(player, flop) print list_to_pretty_str(player), r2t(realrank) rank_clasess.append(r2c(realrank)) print print "nuts = ", nut_hand(flop), ". win = ", evaluator.class_to_string(min(rank_clasess))
Determine winning hand & compare to nut hand.
Determine winning hand & compare to nut hand.
Python
mit
zimolzak/poker-experiments,zimolzak/poker-experiments,zimolzak/poker-experiments
86a2e55954ff4b8f5e005296e2ae336b6be627a0
py/rackattack/clientfactory.py
py/rackattack/clientfactory.py
import os from rackattack.tcp import client _VAR_NAME = "RACKATTACK_PROVIDER" def factory(): if _VAR_NAME not in os.environ: raise Exception( "The environment variable '%s' must be defined properly" % _VAR_NAME) request, subscribe, http = os.environ[_VAR_NAME].split("@@") return client.Client( providerRequestLocation=request, providerSubscribeLocation=subscribe, providerHTTPLocation=http)
import os from rackattack.tcp import client _VAR_NAME = "RACKATTACK_PROVIDER" def factory(connectionString=None): if connectionString is None: if _VAR_NAME not in os.environ: raise Exception( "The environment variable '%s' must be defined properly" % _VAR_NAME) connectionString = os.environ[_VAR_NAME] request, subscribe, http = connectionString.split("@@") return client.Client( providerRequestLocation=request, providerSubscribeLocation=subscribe, providerHTTPLocation=http)
Allow passing the rackattack connection string as an argument to the client factory
Allow passing the rackattack connection string as an argument to the client factory
Python
apache-2.0
eliran-stratoscale/rackattack-api,Stratoscale/rackattack-api
d78fad6937fb20a1ea7374240607b5d6800aa11b
username_to_uuid.py
username_to_uuid.py
""" Username to UUID Converts a Minecraft username to it's UUID equivalent. Parses http://www.lb-stuff.com/Minecraft-Name-History output to retrieve the UUID of an old name that's no longer in use. """ import http.client from bs4 import BeautifulSoup class UsernameToUUID: def __init__(self, username): self.username = username def get_uuid(self): """ Get the UUID of the player. """ httpConn = http.client.HTTPConnection("www.lb-stuff.com"); httpConn.request("GET", "/Minecraft-Name-History?user=" + self.username); response = httpConn.getresponse().read() soup = BeautifulSoup(response) return soup.body.findAll('p')[1].findAll('code')[1].text
""" Username to UUID Converts a Minecraft username to it's UUID equivalent. Uses the official Mojang API to fetch player data. """ import http.client import json class UsernameToUUID: def __init__(self, username): self.username = username def get_uuid(self, timestamp=None): """ Get the UUID of the player. Parameters ---------- timestamp : long integer The time at which the player used this name, expressed as a Unix timestamp. """ get_args = "" if timestamp is None else "?at=" + str(timestamp) http_conn = http.client.HTTPSConnection("api.mojang.com"); http_conn.request("GET", "/users/profiles/minecraft/" + self.username + get_args, headers={'User-Agent':'Minecraft Username -> UUID', 'Content-Type':'application/json'}); response = http_conn.getresponse().read().decode("utf-8") if (not response and timestamp is None): # No response & no timestamp return self.get_uuid(0) # Let's retry with the Unix timestamp 0. if (not response): # No response (player probably doesn't exist) return "" json_data = json.loads(response) uuid = json_data['id'] return uuid
Use the Mojang API directly; reduces overhead.
Use the Mojang API directly; reduces overhead.
Python
mit
mrlolethan/MinecraftUsernameToUUID
43f67067c470386b6b24080642cc845ec1655f58
utils/networking.py
utils/networking.py
import fcntl import socket import struct from contextlib import contextmanager @contextmanager def use_interface(ifname): """ :type ifname: str """ ip = _ip_address_for_interface(ifname.encode('ascii')) original_socket = socket.socket def rebound_socket(*args, **kwargs): sock = original_socket(*args, **kwargs) sock.bind((ip, 0)) return sock socket.socket = rebound_socket yield socket.socket = original_socket def _ip_address_for_interface(ifname): """ :type ifname: bytes :rtype: str """ sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( sock.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24])
import fcntl import socket import struct from contextlib import contextmanager @contextmanager def use_interface(ifname): """ :type ifname: str """ ip = _ip_address_for_interface(ifname) original_socket = socket.socket def rebound_socket(*args, **kwargs): sock = original_socket(*args, **kwargs) sock.bind((ip, 0)) return sock socket.socket = rebound_socket yield socket.socket = original_socket def _ip_address_for_interface(ifname): """ :type ifname: str :rtype: str """ ifname = ifname.encode('ascii') sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) return socket.inet_ntoa(fcntl.ioctl( sock.fileno(), 0x8915, # SIOCGIFADDR struct.pack('256s', ifname[:15]) )[20:24])
Make _ip_address_for_interface easier to use
Make _ip_address_for_interface easier to use
Python
apache-2.0
OPWEN/opwen-webapp,ascoderu/opwen-webapp,ascoderu/opwen-webapp,OPWEN/opwen-webapp,OPWEN/opwen-webapp,ascoderu/opwen-cloudserver,ascoderu/opwen-cloudserver,ascoderu/opwen-webapp
c80a68b81e936435434931f0b5bf748bcbea54dc
statistics/webui.py
statistics/webui.py
from flask import render_template, g, redirect, request from db import connect_db, get_all_sum from statistics import app @app.before_request def before_request(): g.db = connect_db() g.fields = ["CPU", "TOTAL", "SQL", "SOLR", "REDIS", "MEMCACHED"] @app.route("/") def main_page(): sort_by = request.args.get('sort_by', None) data = get_all_sum(g.db) if sort_by: data = sorted(data, key=lambda row: row[sort_by]) return render_template("main_page.html", data=data) @app.route("/add/") def add_page(): key = request.args.get('KEY') for field in g.fields: new_val = int(request.args.get(field, '0')) old_val = int(g.db.hget(key, field) or '0') new_val += old_val g.db.hset(key, field, new_val) g.db.hincrby(key, "REQUESTS", "1") return redirect("/")
from flask import render_template, g, redirect, request from db import connect_db, get_all_sum from statistics import app @app.before_request def before_request(): g.db = connect_db() g.fields = ["CPU", "TOTAL", "SQL", "SOLR", "REDIS", "MEMCACHED"] @app.route("/") def main_page(): sort_by = request.args.get('sort_by', None) data = get_all_sum(g.db) if sort_by: data = sorted(data, key=lambda row: row[sort_by]) return render_template("main_page.html", data=data) @app.route("/average/") def average(): data = get_all_sum(g.db) for row in data: req_count = row['REQUESTS'] for k in row: if k != 'NAME' and k != 'REQUESTS': row[k] = float(row[k])/req_count return render_template("main_page.html", data=data) @app.route("/add/") def add_page(): key = request.args.get('KEY') for field in g.fields: new_val = int(request.args.get(field, '0')) old_val = int(g.db.hget(key, field) or '0') new_val += old_val g.db.hset(key, field, new_val) g.db.hincrby(key, "REQUESTS", "1") return redirect("/")
Add proto of average page. Without sorting.
Add proto of average page. Without sorting.
Python
mit
uvNikita/appstats,uvNikita/appstats,uvNikita/appstats
236a3e81164e8f7c37c50eaf59bfadd32e76735a
defines.py
defines.py
INFINITY = 1e+31 DIRECTIONS = ((-1,-1),(-1,0),(-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)) EMPTY = 0 BLACK = 1 WHITE = 2 def opposite_colour(col): if col == BLACK: return WHITE if col == WHITE: return BLACK
INFINITY = 1e+31 DIRECTIONS = ((-1,-1),(-1,0),(-1,1), (0,-1), (0,1), (1,-1), (1,0), (1,1)) EMPTY = 0 BLACK = 1 WHITE = 2 def opposite_colour(col): if col == BLACK: return WHITE if col == WHITE: return BLACK from pdb import set_trace as st
Make a shortcut for debugging with pdb
Make a shortcut for debugging with pdb
Python
mit
cropleyb/pentai,cropleyb/pentai,cropleyb/pentai
1bd3d7d16da7cc1cf98fa68768910010251f2fea
tests/storage_adapter_tests/test_storage_adapter.py
tests/storage_adapter_tests/test_storage_adapter.py
from unittest import TestCase from chatterbot.storage import StorageAdapter class StorageAdapterTestCase(TestCase): """ This test case is for the StorageAdapter base class. Although this class is not intended for direct use, this test case ensures that exceptions requiring basic functionality are triggered when needed. """ def setUp(self): super(StorageAdapterTestCase, self).setUp() self.adapter = StorageAdapter() def test_count(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.count() def test_filter(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.filter() def test_remove(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.remove('') def test_create(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.create() def test_update(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.update('') def test_get_random(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.get_random() def test_drop(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.drop()
from unittest import TestCase from chatterbot.storage import StorageAdapter class StorageAdapterTestCase(TestCase): """ This test case is for the StorageAdapter base class. Although this class is not intended for direct use, this test case ensures that exceptions requiring basic functionality are triggered when needed. """ def setUp(self): super(StorageAdapterTestCase, self).setUp() self.adapter = StorageAdapter() def test_count(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.count() def test_filter(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.filter() def test_remove(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.remove('') def test_create(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.create() def test_update(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.update('') def test_get_random(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.get_random() def test_drop(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.drop() def test_get_response_statements(self): with self.assertRaises(StorageAdapter.AdapterMethodNotImplementedError): self.adapter.get_response_statements()
Add test for unimplemented get_response_statements function
Add test for unimplemented get_response_statements function
Python
bsd-3-clause
gunthercox/ChatterBot,vkosuri/ChatterBot
67b243915ef95ff1b9337bc67053d18df372e79d
unitypack/enums.py
unitypack/enums.py
from enum import IntEnum class RuntimePlatform(IntEnum): OSXEditor = 0 OSXPlayer = 1 WindowsPlayer = 2 OSXWebPlayer = 3 OSXDashboardPlayer = 4 WindowsWebPlayer = 5 WindowsEditor = 7 IPhonePlayer = 8 PS3 = 9 XBOX360 = 10 Android = 11 NaCl = 12 LinuxPlayer = 13 FlashPlayer = 15 WebGLPlayer = 17 MetroPlayerX86 = 18 WSAPlayerX86 = 18 MetroPlayerX64 = 19 WSAPlayerX64 = 19 MetroPlayerARM = 20 WSAPlayerARM = 20 WP8Player = 21 BB10Player = 22 BlackBerryPlayer = 22 TizenPlayer = 23 PSP2 = 24 PS4 = 25 PSM = 26 XboxOne = 27
from enum import IntEnum class RuntimePlatform(IntEnum): OSXEditor = 0 OSXPlayer = 1 WindowsPlayer = 2 OSXWebPlayer = 3 OSXDashboardPlayer = 4 WindowsWebPlayer = 5 WindowsEditor = 7 IPhonePlayer = 8 PS3 = 9 XBOX360 = 10 Android = 11 NaCl = 12 LinuxPlayer = 13 FlashPlayer = 15 WebGLPlayer = 17 MetroPlayerX86 = 18 WSAPlayerX86 = 18 MetroPlayerX64 = 19 WSAPlayerX64 = 19 MetroPlayerARM = 20 WSAPlayerARM = 20 WP8Player = 21 BB10Player = 22 BlackBerryPlayer = 22 TizenPlayer = 23 PSP2 = 24 PS4 = 25 PSM = 26 PSMPlayer = 26 XboxOne = 27 SamsungTVPlayer = 28
Add PSMPlayer and SamsungTVPlayer platforms
Add PSMPlayer and SamsungTVPlayer platforms
Python
mit
andburn/python-unitypack
c4de9152f34d2831d43dfa3769a7a6452bba5814
blockbuster/bb_security.py
blockbuster/bb_security.py
__author__ = 'matt' from blockbuster import bb_dbconnector_factory def credentials_are_valid(username, password): db = bb_dbconnector_factory.DBConnectorInterfaceFactory().create() print(username) result = db.api_username_exists(username) print (result) return result
__author__ = 'matt' from blockbuster import bb_dbconnector_factory def credentials_are_valid(username, password): db = bb_dbconnector_factory.DBConnectorInterfaceFactory().create() print(username) result = db.api_credentials_are_valid(username, password) print (result) return result
Update method to check both username and password
Update method to check both username and password
Python
mit
mattstibbs/blockbuster-server,mattstibbs/blockbuster-server
b28a40e38f0cbd40e01906063b97731ba6cd3fb6
backend/geonature/core/gn_profiles/models.py
backend/geonature/core/gn_profiles/models.py
from geonature.utils.env import DB from utils_flask_sqla.serializers import serializable @serializable class VmCorTaxonPhenology(DB.Model): __tablename__ = "vm_cor_taxon_phenology" __table_args__ = {"schema": "gn_profiles"} cd_ref = DB.Column(DB.Integer, primary_key=True) period = DB.Column(DB.Integer) id_nomenclature_life_stage = DB.Column(DB.Integer) id_altitude_range = DB.Column(DB.Integer) count_valid_data = DB.Column(DB.Integer)
from flask import current_app from geoalchemy2 import Geometry from utils_flask_sqla.serializers import serializable from utils_flask_sqla_geo.serializers import geoserializable from geonature.utils.env import DB @serializable class VmCorTaxonPhenology(DB.Model): __tablename__ = "vm_cor_taxon_phenology" __table_args__ = {"schema": "gn_profiles"} cd_ref = DB.Column(DB.Integer, primary_key=True) period = DB.Column(DB.Integer) id_nomenclature_life_stage = DB.Column(DB.Integer) id_altitude_range = DB.Column(DB.Integer) count_valid_data = DB.Column(DB.Integer) @serializable @geoserializable class VmValidProfiles(DB.Model): __tablename__ = "vm_valid_profiles" __table_args__ = {"schema": "gn_profiles"} cd_ref = DB.Column(DB.Integer) valid_distribution = DB.Column(Geometry("GEOMETRY", current_app.config["LOCAL_SRID"])) altitude_min = DB.Column(DB.Integer) altitude_max = DB.Column(DB.Integer) first_valid_data = DB.Column(DB.DateTime) last_valid_data = DB.Column(DB.DateTime) count_valid_data = DB.Column(DB.Integer)
Add VM valid profile model
Add VM valid profile model
Python
bsd-2-clause
PnEcrins/GeoNature,PnEcrins/GeoNature,PnEcrins/GeoNature,PnEcrins/GeoNature
80531076a713618cda6de815bdd6675bdf6f85f1
bluebottle/clients/management/commands/export_tenants.py
bluebottle/clients/management/commands/export_tenants.py
import json from rest_framework.authtoken.models import Token from django.contrib.contenttypes.models import ContentType from django.core.management.base import BaseCommand from bluebottle.clients import properties from bluebottle.clients.models import Client from bluebottle.clients.utils import LocalTenant class Command(BaseCommand): help = 'Export tenants, so that we can import them into the accounting app' def add_arguments(self, parser): parser.add_argument('--file', type=str, default=None, action='store') def handle(self, *args, **options): results = [] for client in Client.objects.all(): properties.set_tenant(client) with LocalTenant(client, clear_tenant=True): ContentType.objects.clear_cache() accounts = [] for merchant in properties.MERCHANT_ACCOUNTS: if merchant['merchant'] == 'docdata': accounts.append( { 'service_type': 'docdata', 'username': merchant['merchant_name'] } ) api_key = Token.objects.get(user__username='accounting').key results.append({ "name": client.schema_name, "domain": properties.TENANT_MAIL_PROPERTIES['website'], "api_key": api_key, "accounts": accounts }) if options['file']: text_file = open(options['file'], "w") text_file.write(json.dumps(results)) text_file.close() else: print json.dumps(results)
import json from rest_framework.authtoken.models import Token from django.contrib.contenttypes.models import ContentType from django.core.management.base import BaseCommand from bluebottle.clients import properties from bluebottle.clients.models import Client from bluebottle.clients.utils import LocalTenant class Command(BaseCommand): help = 'Export tenants, so that we can import them into the accounting app' def add_arguments(self, parser): parser.add_argument('--file', type=str, default=None, action='store') def handle(self, *args, **options): results = [] for client in Client.objects.all(): properties.set_tenant(client) with LocalTenant(client, clear_tenant=True): ContentType.objects.clear_cache() accounts = [] for merchant in properties.MERCHANT_ACCOUNTS: if merchant['merchant'] == 'docdata': accounts.append( { 'service_type': 'docdata', 'username': merchant['merchant_name'] } ) api_key = Token.objects.get(user__username='accounting').key results.append({ "name": client.client_name, "domain": properties.TENANT_MAIL_PROPERTIES['website'], "api_key": api_key, "accounts": accounts }) if options['file']: text_file = open(options['file'], "w") text_file.write(json.dumps(results)) text_file.close() else: print json.dumps(results)
Use client_name instead of schema_name
Use client_name instead of schema_name
Python
bsd-3-clause
onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle,onepercentclub/bluebottle
753f5bdc3f023cf31c0f189dd835978aad2b5d49
djs_playground/urls.py
djs_playground/urls.py
from django.conf import settings from django.conf.urls import url, include from django.conf.urls.static import static from django.contrib import admin from djs_playground.views import index urlpatterns = [ url(r'^$', index, name='index'), url(r'^admin/', admin.site.urls), url(r'^summernote/', include('django_summernote.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.conf import settings from django.urls import re_path, include from django.conf.urls.static import static from django.contrib import admin from djs_playground.views import index urlpatterns = [ re_path(r'^$', index, name='index'), re_path(r'^admin/', admin.site.urls), re_path(r'^summernote/', include('django_summernote.urls')), ] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
Change url in favor of the re_path
Change url in favor of the re_path
Python
mit
summernote/django-summernote,summernote/django-summernote,summernote/django-summernote
5a641736faf6bb3ce335480848464a1f22fab040
fabfile.py
fabfile.py
# -*- coding: utf-8 -*- from contextlib import nested from fabric.api import * def prepare_project(): u""" Enters the directory and sources environment configuration. I know ``nested`` is deprecated, but what a nice shortcut it is here ;) """ return nested( cd(PROJECT_PATH), prefix("source ../.virtualenvs/variablestars3/bin/activate") ) PROJECT_PATH = "$HOME/variablestars.net" env.roledefs = { 'web': ["[email protected]"], } env.color = True env.forward_agent = True @task @roles("web") def git_pull(): with cd(PROJECT_PATH): run("git pull origin master") @task @roles("web") def update_requirements(): with prepare_project(): run("pip install -r requirements.txt") run("source ~/.nvm/nvm.sh && npm install") @task @roles("web") def migrate(): with prepare_project(): run("python manage.py syncdb") run("python manage.py migrate") @task @roles("web") def collect_static(): with prepare_project(): run("python manage.py collectstatic --noinput") @task @roles("web") def restart(): run("appctl restart variablestars2") @task @roles("web") def deploy(): git_pull() update_requirements() migrate() collect_static() restart()
# -*- coding: utf-8 -*- from contextlib import nested from fabric.api import * def prepare_project(): u""" Enters the directory and sources environment configuration. I know ``nested`` is deprecated, but what a nice shortcut it is here ;) """ return nested( cd(PROJECT_PATH), prefix("source ../.virtualenvs/variablestars3/bin/activate") ) PROJECT_PATH = "$HOME/variablestars.net" env.roledefs = { 'web': ["[email protected]"], } env.color = True env.forward_agent = True env.use_ssh_config = True @task @roles("web") def git_pull(): with cd(PROJECT_PATH): run("git pull origin master") @task @roles("web") def update_requirements(): with prepare_project(): run("pip install -r requirements.txt") run("source ~/.nvm/nvm.sh && npm install") @task @roles("web") def migrate(): with prepare_project(): run("python manage.py syncdb") run("python manage.py migrate") @task @roles("web") def collect_static(): with prepare_project(): run("python manage.py collectstatic --noinput") @task @roles("web") def restart(): run("appctl restart variablestars2") @task @roles("web") def deploy(): git_pull() update_requirements() migrate() collect_static() restart()
Make Fabric honor .ssh/config settings
Make Fabric honor .ssh/config settings
Python
mit
zsiciarz/variablestars.net,zsiciarz/variablestars.net,zsiciarz/variablestars.net
dc1cf6fabcf871e3661125f7ac5d1cf9567798d6
cms/management/commands/load_dev_fixtures.py
cms/management/commands/load_dev_fixtures.py
import requests from django.core.management import call_command from django.core.management.base import NoArgsCommand from django.conf import settings from django.utils.six.moves import input class Command(NoArgsCommand): """ Download and load dev fixtures from www.python.org """ help = "Download and load dev fixtures from python.org" def handle_noargs(self, **options): # Confirm the user wants to do this confirm = input("""You have requested to load the python.org development fixtures. This will IRREVERSIBLY DESTROY all data currently in your local database. Are you sure you want to do this? Type 'y' or 'yes' to continue, 'n' or 'no' to cancel: """) if confirm in ('y', 'yes'): if confirm: print() print("Beginning download, note this can take a couple of minutes...") r = requests.get(settings.DEV_FIXTURE_URL, stream=True) if r.status_code != 200: print("Unable to download file: Received status code {}".format(r.status_code)) with open('/tmp/dev-fixtures.json.gz', 'wb') as f: for chunk in r.iter_content(chunk_size=1024): f.write(chunk) f.flush() print("Download complete, loading fixtures") call_command('loaddata', '/tmp/dev-fixtures.json') print("END: Fixtures loaded")
import requests from django.core.management import call_command from django.core.management.base import NoArgsCommand from django.conf import settings from django.utils.six.moves import input class Command(NoArgsCommand): """ Download and load dev fixtures from www.python.org """ help = "Download and load dev fixtures from python.org" def handle_noargs(self, **options): # Confirm the user wants to do this confirm = input("""You have requested to load the python.org development fixtures. This will IRREVERSIBLY DESTROY all data currently in your local database. Are you sure you want to do this? Type 'y' or 'yes' to continue, 'n' or 'no' to cancel: """) if confirm in ('y', 'yes'): self.stdout.write("\nBeginning download, note this can take a couple of minutes...") r = requests.get(settings.DEV_FIXTURE_URL, stream=True) if r.status_code != 200: self.stdout.write("Unable to download file: Received status code {}".format(r.status_code)) with open('/tmp/dev-fixtures.json.gz', 'wb') as f: for chunk in r.iter_content(chunk_size=1024): f.write(chunk) f.flush() self.stdout.write("Download complete, loading fixtures") call_command('loaddata', '/tmp/dev-fixtures.json') self.stdout.write("END: Fixtures loaded")
Use self.stdout.write() instead of print().
Use self.stdout.write() instead of print(). This is the recommended way in the Django documentation: https://docs.djangoproject.com/en/1.7/howto/custom-management-commands/
Python
apache-2.0
manhhomienbienthuy/pythondotorg,python/pythondotorg,SujaySKumar/pythondotorg,lebronhkh/pythondotorg,SujaySKumar/pythondotorg,lepture/pythondotorg,python/pythondotorg,proevo/pythondotorg,Mariatta/pythondotorg,malemburg/pythondotorg,willingc/pythondotorg,fe11x/pythondotorg,berkerpeksag/pythondotorg,demvher/pythondotorg,python/pythondotorg,SujaySKumar/pythondotorg,berkerpeksag/pythondotorg,lepture/pythondotorg,manhhomienbienthuy/pythondotorg,ahua/pythondotorg,Mariatta/pythondotorg,lepture/pythondotorg,malemburg/pythondotorg,demvher/pythondotorg,fe11x/pythondotorg,SujaySKumar/pythondotorg,willingc/pythondotorg,Mariatta/pythondotorg,demvher/pythondotorg,proevo/pythondotorg,proevo/pythondotorg,SujaySKumar/pythondotorg,demvher/pythondotorg,ahua/pythondotorg,fe11x/pythondotorg,proevo/pythondotorg,manhhomienbienthuy/pythondotorg,fe11x/pythondotorg,willingc/pythondotorg,lebronhkh/pythondotorg,lepture/pythondotorg,berkerpeksag/pythondotorg,ahua/pythondotorg,manhhomienbienthuy/pythondotorg,Mariatta/pythondotorg,malemburg/pythondotorg,berkerpeksag/pythondotorg,lebronhkh/pythondotorg,ahua/pythondotorg,malemburg/pythondotorg,lepture/pythondotorg,fe11x/pythondotorg,willingc/pythondotorg,python/pythondotorg,ahua/pythondotorg,lebronhkh/pythondotorg,lebronhkh/pythondotorg,demvher/pythondotorg,berkerpeksag/pythondotorg
06f0edb71086573a3d7f9efb01b97b073cf415a3
tests/DdlTextWrterTest.py
tests/DdlTextWrterTest.py
import io import os import unittest from pyddl import * __author__ = "Jonathan Hale" class DdlTextWriterTest(unittest.TestCase): def tearDown(self): try: os.remove("test.oddl") except FileNotFoundError: pass # test_empty failed? def test_empty(self): # create document document = DdlDocument() # write document DdlTextWriter(document).write("test.oddl") # check if file was created try: self.assertTrue(os.path.isfile("test.oddl")) except FileNotFoundError: self.fail("DdlTextWriter did not create the specified file.") def test_full(self): self.assertTrue(True) pass if __name__ == "__main__": unittest.main()
import os import unittest from pyddl import * from pyddl.enum import * __author__ = "Jonathan Hale" class DdlTextWriterTest(unittest.TestCase): def tearDown(self): try: os.remove("test.oddl") except FileNotFoundError: pass # test_empty failed? def test_empty(self): # create document document = DdlDocument() # write document DdlTextWriter(document).write("test.oddl") # check if file was created try: self.assertTrue(os.path.isfile("test.oddl")) except FileNotFoundError: self.fail("DdlTextWriter did not create the specified file.") def test_full(self): # create document document = DdlDocument() document.add_structure(B"Human", None, [DdlStructure(B"Name", None, [DdlPrimitive(PrimitiveType.string, ["Peter"])]), DdlStructure(B"Age", None, [DdlPrimitive(PrimitiveType.unsigned_int16, [21])])] ) # write document DdlTextWriter(document).write("test.oddl") if __name__ == "__main__": unittest.main()
Create a document in DdlTextWriterTest.test_full()
Create a document in DdlTextWriterTest.test_full() Signed-off-by: Squareys <[email protected]>
Python
mit
Squareys/PyDDL
125dfa47e5656c3f9b1e8846be03010ed02c6f91
tests/rules_tests/isValid_tests/InvalidSyntaxTest.py
tests/rules_tests/isValid_tests/InvalidSyntaxTest.py
#!/usr/bin/env python """ :Author Patrik Valkovic :Created 23.06.2017 16:39 :Licence GNUv3 Part of grammpy """ from unittest import main, TestCase from grammpy import Rule class InvalidSyntaxTest(TestCase): pass if __name__ == '__main__': main()
#!/usr/bin/env python """ :Author Patrik Valkovic :Created 23.06.2017 16:39 :Licence GNUv3 Part of grammpy """ from unittest import main, TestCase from grammpy import Rule from grammpy.exceptions import RuleSyntaxException from .grammar import * class InvalidSyntaxTest(TestCase): def test_rulesMissingEncloseList(self): class tmp(Rule): rules = ([0], [1]) with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_rulesMissingTuple(self): class tmp(Rule): rules = [[0], [1]] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_rulesMissingInnerLeftList(self): class tmp(Rule): rules = [(0, [1])] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_rulesMissingInnerRightList(self): class tmp(Rule): rules = [([0], 1)] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_multipleRulesMissingInnerLeftList(self): class tmp(Rule): rules = [(NFirst, TSecond), (0, [1])] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_multipleRulesMissingInnerRightList(self): class tmp(Rule): rules = [(NFifth, TFirst), ([0], 1)] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_emptyRule(self): class tmp(Rule): rules = [([], [])] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_emptyOneOfRules(self): class tmp(Rule): rules = [(NFifth, TFirst), ([], [])] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_onlyOuterArray(self): class tmp(Rule): rules = [NFifth, TFirst] with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) def test_outerIsTuple(self): class tmp(Rule): rules = (([NFirst], [TSecond]), ([0], [1])) with self.assertRaises(RuleSyntaxException): tmp.validate(grammar) if __name__ == '__main__': main()
Add base set of rule's invalid syntax tests
Add base set of rule's invalid syntax tests
Python
mit
PatrikValkovic/grammpy
12cb8ca101faa09e4cc07f9e257b3d3130892297
tests/sentry/web/frontend/tests.py
tests/sentry/web/frontend/tests.py
# -*- coding: utf-8 -*- from __future__ import absolute_import import pytest from django.core.urlresolvers import reverse from exam import fixture from sentry.testutils import TestCase @pytest.mark.xfail class ReplayTest(TestCase): @fixture def path(self): return reverse('sentry-replay', kwargs={ 'organization_slug': self.organization.slug, 'project_id': self.project.slug, 'group_id': self.group.id, 'event_id': self.event.id, }) def test_does_render(self): self.login_as(self.user) resp = self.client.get(self.path) self.assertEquals(resp.status_code, 200) self.assertTemplateUsed(resp, 'sentry/events/replay_request.html')
# -*- coding: utf-8 -*- from __future__ import absolute_import from django.core.urlresolvers import reverse from exam import fixture from sentry.testutils import TestCase class ReplayTest(TestCase): @fixture def path(self): return reverse('sentry-replay', kwargs={ 'organization_slug': self.organization.slug, 'project_id': self.project.slug, 'group_id': self.group.id, 'event_id': self.event.id, }) def test_does_render(self): self.login_as(self.user) resp = self.client.get(self.path) self.assertEquals(resp.status_code, 200) self.assertTemplateUsed(resp, 'sentry/events/replay_request.html')
Remove xfail from replay test
Remove xfail from replay test
Python
bsd-3-clause
mitsuhiko/sentry,fotinakis/sentry,beeftornado/sentry,mvaled/sentry,mvaled/sentry,BuildingLink/sentry,alexm92/sentry,mvaled/sentry,mvaled/sentry,BuildingLink/sentry,nicholasserra/sentry,JackDanger/sentry,fotinakis/sentry,gencer/sentry,fotinakis/sentry,beeftornado/sentry,ifduyue/sentry,JamesMura/sentry,imankulov/sentry,looker/sentry,imankulov/sentry,zenefits/sentry,mvaled/sentry,JamesMura/sentry,gencer/sentry,daevaorn/sentry,JackDanger/sentry,zenefits/sentry,JamesMura/sentry,nicholasserra/sentry,ifduyue/sentry,mvaled/sentry,zenefits/sentry,gencer/sentry,looker/sentry,daevaorn/sentry,beeftornado/sentry,imankulov/sentry,JamesMura/sentry,looker/sentry,BuildingLink/sentry,daevaorn/sentry,ifduyue/sentry,looker/sentry,BuildingLink/sentry,fotinakis/sentry,JackDanger/sentry,zenefits/sentry,jean/sentry,nicholasserra/sentry,alexm92/sentry,zenefits/sentry,JamesMura/sentry,looker/sentry,jean/sentry,mitsuhiko/sentry,alexm92/sentry,ifduyue/sentry,gencer/sentry,daevaorn/sentry,jean/sentry,gencer/sentry,BuildingLink/sentry,jean/sentry,jean/sentry,ifduyue/sentry
f920f7e765dac7057e3c48ebe0aa9723c3d431f5
src/cclib/progress/__init__.py
src/cclib/progress/__init__.py
__revision__ = "$Revision$" from textprogress import TextProgress try: import qt except ImportError: pass # import QtProgress will cause an error else: from qtprogress import QtProgress
__revision__ = "$Revision$" from textprogress import TextProgress import sys if 'qt' in sys.modules.keys(): from qtprogress import QtProgress
Check to see if qt is loaded; if so, export QtProgress class
Check to see if qt is loaded; if so, export QtProgress class git-svn-id: d468cea6ffe92bc1eb1f3bde47ad7e70b065426a@224 5acbf244-8a03-4a8b-a19b-0d601add4d27
Python
lgpl-2.1
Clyde-fare/cclib_bak,Clyde-fare/cclib_bak
23675e41656cac48f390d97f065b36de39e27d58
duckbot.py
duckbot.py
import discord import duckbot_settings import random from discord.ext import commands _DESCRIPTION = '''quack''' bot = commands.Bot(command_prefix='/', description=_DESCRIPTION) @bot.event async def on_ready(): print('logged in: %s (%s)' % (bot.user.name, bot.user.id)) oauth_url = discord.utils.oauth_url(duckbot_settings.CLIENT_ID, permissions=discord.Permissions.text()) print('invite me: %s' % oauth_url) print('Channels:') channels = bot.get_all_channels() for channel in channels: print('%s (%s)' % (channel.name, channel.id)) if channel.name == 'botspam': await bot.send_message(channel, 'quack!! (ready to roll)') @bot.command() async def roll(): await bot.say('pretending to roll') bot.run(duckbot_settings.TOKEN)
import discord import duckbot_settings import random from discord.ext import commands _DESCRIPTION = '''quack''' bot = commands.Bot(command_prefix='/', description=_DESCRIPTION) rand = random.SystemRandom() @bot.event async def on_ready(): print('logged in: %s (%s)' % (bot.user.name, bot.user.id)) oauth_url = discord.utils.oauth_url(duckbot_settings.CLIENT_ID, permissions=discord.Permissions.text()) print('invite me: %s' % oauth_url) print('Channels:') channels = bot.get_all_channels() for channel in channels: print('%s (%s)' % (channel.name, channel.id)) if channel.name == 'botspam': await bot.send_message(channel, 'quack!! (ready to roll)') @bot.command() async def roll(): lower_bound = 1 upper_boundb = 6 await bot.say('🎲 (%d-%d): %d' % (lower_bound, upper_bound, rand.randint(lower_bound, upper_bound))) bot.run(duckbot_settings.TOKEN)
Add a real roll command
Add a real roll command
Python
mit
andrewlin16/duckbot,andrewlin16/duckbot
30ed3800fdeec4aec399e6e0ec0760e46eb891ec
djangoautoconf/model_utils/model_reversion.py
djangoautoconf/model_utils/model_reversion.py
from django.contrib.contenttypes.models import ContentType from django.db.models.signals import pre_save from django.dispatch import receiver from reversion.models import Version from reversion.revisions import default_revision_manager global_save_signal_receiver = [] class PreSaveHandler(object): def __init__(self, model_inst): super(PreSaveHandler, self).__init__() self.model_inst = model_inst def object_save_handler(self, sender, instance, **kwargs): # logging.error("======================================") if not (instance.pk is None): content_type = ContentType.objects.get_for_model(self.model_inst) versioned_pk_queryset = Version.objects.filter(content_type=content_type).filter(object_id_int=instance.pk) if not versioned_pk_queryset.exists(): item = self.model_inst.objects.get(pk=instance.pk) try: default_revision_manager.save_revision((item,)) except: pass def add_reversion_before_save(model_inst): s = PreSaveHandler(model_inst) global_save_signal_receiver.append(s) receiver(pre_save, sender=model_inst)(s.object_save_handler)
from django.contrib.contenttypes.models import ContentType from django.db.models.signals import pre_save from django.dispatch import receiver from reversion.models import Version def create_initial_version(obj): try: from reversion.revisions import default_revision_manager default_revision_manager.save_revision((obj,)) except: from reversion.revisions import add_to_revision add_to_revision(obj) global_save_signal_receiver = [] class PreSaveHandler(object): def __init__(self, model_inst): super(PreSaveHandler, self).__init__() self.model_inst = model_inst def object_save_handler(self, sender, instance, **kwargs): # logging.error("======================================") if not (instance.pk is None): content_type = ContentType.objects.get_for_model(self.model_inst) versioned_pk_queryset = Version.objects.filter(content_type=content_type).filter(object_id_int=instance.pk) if not versioned_pk_queryset.exists(): item = self.model_inst.objects.get(pk=instance.pk) try: create_initial_version(item) except: pass def add_reversion_before_save(model_inst): s = PreSaveHandler(model_inst) global_save_signal_receiver.append(s) receiver(pre_save, sender=model_inst)(s.object_save_handler)
Fix broken initial version creation.
Fix broken initial version creation.
Python
bsd-3-clause
weijia/djangoautoconf,weijia/djangoautoconf
5237cb7f1339eb13b4c01f1c3611448a8f865726
terms/templatetags/terms.py
terms/templatetags/terms.py
# coding: utf-8 from django.template import Library from ..html import TermsHTMLReconstructor register = Library() @register.filter def replace_terms(html): parser = TermsHTMLReconstructor() parser.feed(html) return parser.out
# coding: utf-8 from django.template import Library from django.template.defaultfilters import stringfilter from ..html import TermsHTMLReconstructor register = Library() @register.filter @stringfilter def replace_terms(html): parser = TermsHTMLReconstructor() parser.feed(html) return parser.out
Make sure the filter arg is a string.
Make sure the filter arg is a string.
Python
bsd-3-clause
BertrandBordage/django-terms,philippeowagner/django-terms,BertrandBordage/django-terms,philippeowagner/django-terms
1b218de76e8b09c70abcd88a2c6dd2c043bfc7f0
drcli/__main__.py
drcli/__main__.py
#!/usr/bin/env python import os.path import sys import imp import argparse from api import App, add_subparsers def load_plugins(dir): for f in os.listdir(dir): module_name, ext = os.path.splitext(f) if ext == '.py': imp.load_source('arbitrary', os.path.join(dir, f)) def main(args=sys.argv[1:]): load_plugins(os.path.join(os.path.dirname(__file__), 'plugins/evaluators')) load_plugins(os.path.join(os.path.dirname(__file__), 'plugins/apps')) parser = argparse.ArgumentParser() add_subparsers(parser, sorted(App.CLASSES.items()), 'app_cls', title='apps') args = parser.parse_args() args.app_cls(parser, args)() if __name__ == '__main__': main(sys.argv[1:])
#!/usr/bin/env python import os.path import sys import imp import argparse from api import App, add_subparsers def load_plugins(dir): for f in os.listdir(dir): module_name, ext = os.path.splitext(f) if ext == '.py': imp.load_source('arbitrary', os.path.join(dir, f)) def main(args=None): if args is None: args = sys.argv[1:] cmd = os.path.basename(sys.argv[0]) if cmd.startswith('dr-'): args.insert(0, cmd[3:]) prog = 'dr' else: prog = None load_plugins(os.path.join(os.path.dirname(__file__), 'plugins/evaluators')) load_plugins(os.path.join(os.path.dirname(__file__), 'plugins/apps')) parser = argparse.ArgumentParser(prog=prog) add_subparsers(parser, sorted(App.CLASSES.items()), 'app_cls', title='apps') args = parser.parse_args(args) args.app_cls(parser, args)() if __name__ == '__main__': main()
Allow sub-commands to use same main function
Allow sub-commands to use same main function
Python
mit
schwa-lab/dr-apps-python
85d684369e72aa2968f9ffbd0632f84558e1b44e
tests/test_vector2_dot.py
tests/test_vector2_dot.py
from ppb_vector import Vector2 from math import isclose, sqrt import pytest # type: ignore from hypothesis import assume, given, note from utils import floats, vectors @given(x=vectors(), y=vectors()) def test_dot_commutes(x: Vector2, y: Vector2): assert x * y == y * x MAGNITUDE=1e10 @given(x=vectors(max_magnitude=MAGNITUDE), z=vectors(max_magnitude=MAGNITUDE), y=vectors(max_magnitude=sqrt(MAGNITUDE)), scalar=floats(max_magnitude=sqrt(MAGNITUDE))) def test_dot_linear(x: Vector2, y: Vector2, z: Vector2, scalar: float): """Test that x · (λ y + z) = λ x·y + x·z""" inner, outer = x * (scalar * y + z), scalar * x * y + x * z note(f"inner: {inner}") note(f"outer: {outer}") assert isclose(inner, outer, abs_tol=1e-5, rel_tol=1e-5)
from ppb_vector import Vector2 from math import isclose, sqrt import pytest # type: ignore from hypothesis import assume, given, note from utils import floats, vectors @given(x=vectors(), y=vectors()) def test_dot_commutes(x: Vector2, y: Vector2): assert x * y == y * x @given(x=vectors()) def test_dot_length(x: Vector2): assert isclose(x * x, x.length * x.length) MAGNITUDE=1e10 @given(x=vectors(max_magnitude=MAGNITUDE), z=vectors(max_magnitude=MAGNITUDE), y=vectors(max_magnitude=sqrt(MAGNITUDE)), scalar=floats(max_magnitude=sqrt(MAGNITUDE))) def test_dot_linear(x: Vector2, y: Vector2, z: Vector2, scalar: float): """Test that x · (λ y + z) = λ x·y + x·z""" inner, outer = x * (scalar * y + z), scalar * x * y + x * z note(f"inner: {inner}") note(f"outer: {outer}") assert isclose(inner, outer, abs_tol=1e-5, rel_tol=1e-5)
Test that x² == |x|²
tests/dot: Test that x² == |x|²
Python
artistic-2.0
ppb/ppb-vector,ppb/ppb-vector
99e1377deb066b9bee64b40799caaeaccd0db7d8
src/conditions/signals.py
src/conditions/signals.py
# coding: utf-8 import os import traceback from .handlers import find_handler _activate_debugger = os.environ.get('DEBUG') == 'yes' if _activate_debugger: try: from trepan.api import debug set_trace = debug except ImportError: import pdb set_trace = pdb.set_trace def signal(e): """ Some docstrings. """ callback = find_handler(e) if callback is None: if _activate_debugger: print 'Handler for error {0} not found'.format(type(e)) traceback.print_stack() set_trace() raise e else: return callback(e)
# coding: utf-8 from __future__ import print_function import os import traceback from .handlers import find_handler _activate_debugger = os.environ.get('DEBUG') == 'yes' if _activate_debugger: try: from trepan.api import debug set_trace = debug except ImportError: import pdb set_trace = pdb.set_trace def signal(e): """ Some docstrings. """ callback = find_handler(e) if callback is None: if _activate_debugger: print('Handler for error {0} not found'.format(type(e))) traceback.print_stack() set_trace() raise e else: return callback(e)
Fix use of Python 2 print
Fix use of Python 2 print
Python
bsd-2-clause
svetlyak40wt/python-cl-conditions
fd81c4cea0d28275123539c23c27dcfdd71e9aef
scipy/testing/nulltester.py
scipy/testing/nulltester.py
''' Null tester (when nose not importable) Merely returns error reporting lack of nose package See pkgtester, nosetester modules ''' nose_url = 'http://somethingaboutorange.com/mrl/projects/nose' class NullTester(object): def __init__(self, *args, **kwargs): pass def test(self, labels=None, *args, **kwargs): raise ImportError, 'Need nose for tests - see %s' % nose_url
''' Null tester (when nose not importable) Merely returns error reporting lack of nose package See pkgtester, nosetester modules ''' nose_url = 'http://somethingaboutorange.com/mrl/projects/nose' class NullTester(object): def __init__(self, *args, **kwargs): pass def test(self, labels=None, *args, **kwargs): raise ImportError, 'Need nose for tests - see %s' % nose_url def bench(self, labels=None, *args, **kwargs): raise ImportError, 'Need nose for benchmarks - see %s' % nose_url
Fix bench error on scipy import when nose is not installed
Fix bench error on scipy import when nose is not installed
Python
bsd-3-clause
aman-iitj/scipy,maciejkula/scipy,efiring/scipy,gfyoung/scipy,teoliphant/scipy,pizzathief/scipy,pbrod/scipy,Eric89GXL/scipy,jor-/scipy,larsmans/scipy,anntzer/scipy,behzadnouri/scipy,pschella/scipy,ogrisel/scipy,sriki18/scipy,aarchiba/scipy,WarrenWeckesser/scipy,newemailjdm/scipy,Srisai85/scipy,pbrod/scipy,surhudm/scipy,niknow/scipy,hainm/scipy,sriki18/scipy,fredrikw/scipy,ales-erjavec/scipy,raoulbq/scipy,mingwpy/scipy,bkendzior/scipy,ales-erjavec/scipy,witcxc/scipy,matthew-brett/scipy,pyramania/scipy,matthew-brett/scipy,woodscn/scipy,gfyoung/scipy,giorgiop/scipy,mortada/scipy,kalvdans/scipy,piyush0609/scipy,WillieMaddox/scipy,juliantaylor/scipy,haudren/scipy,aman-iitj/scipy,efiring/scipy,gdooper/scipy,vigna/scipy,apbard/scipy,nvoron23/scipy,jseabold/scipy,anielsen001/scipy,mortonjt/scipy,person142/scipy,jjhelmus/scipy,mgaitan/scipy,FRidh/scipy,ndchorley/scipy,Gillu13/scipy,gef756/scipy,kalvdans/scipy,mortada/scipy,rmcgibbo/scipy,zaxliu/scipy,mikebenfield/scipy,vigna/scipy,teoliphant/scipy,rgommers/scipy,ortylp/scipy,minhlongdo/scipy,Kamp9/scipy,aarchiba/scipy,gertingold/scipy,sauliusl/scipy,vhaasteren/scipy,anntzer/scipy,perimosocordiae/scipy,Srisai85/scipy,ChanderG/scipy,andim/scipy,rgommers/scipy,fernand/scipy,richardotis/scipy,vberaudi/scipy,lukauskas/scipy,mtrbean/scipy,piyush0609/scipy,maciejkula/scipy,sonnyhu/scipy,mhogg/scipy,teoliphant/scipy,scipy/scipy,Srisai85/scipy,chatcannon/scipy,vanpact/scipy,aeklant/scipy,kleskjr/scipy,maniteja123/scipy,petebachant/scipy,zxsted/scipy,rmcgibbo/scipy,petebachant/scipy,gef756/scipy,trankmichael/scipy,nmayorov/scipy,andyfaff/scipy,apbard/scipy,nonhermitian/scipy,gdooper/scipy,vanpact/scipy,pizzathief/scipy,Kamp9/scipy,vberaudi/scipy,pizzathief/scipy,nmayorov/scipy,ortylp/scipy,jsilter/scipy,kleskjr/scipy,mortonjt/scipy,nvoron23/scipy,haudren/scipy,nonhermitian/scipy,pschella/scipy,jonycgn/scipy,trankmichael/scipy,newemailjdm/scipy,woodscn/scipy,zerothi/scipy,zaxliu/scipy,endolith/scipy,dominicelse/scipy,mtrbean/scipy,juliantaylor/scipy,futurulus/scipy,jjhelmus/scipy,ChanderG/scipy,jseabold/scipy,pyramania/scipy,ilayn/scipy,dominicelse/scipy,Gillu13/scipy,anntzer/scipy,matthewalbani/scipy,lhilt/scipy,ilayn/scipy,niknow/scipy,bkendzior/scipy,sriki18/scipy,nvoron23/scipy,Stefan-Endres/scipy,andyfaff/scipy,andim/scipy,haudren/scipy,kalvdans/scipy,rmcgibbo/scipy,zxsted/scipy,hainm/scipy,pschella/scipy,lukauskas/scipy,mingwpy/scipy,jor-/scipy,Srisai85/scipy,ilayn/scipy,woodscn/scipy,nmayorov/scipy,jor-/scipy,Shaswat27/scipy,argriffing/scipy,vhaasteren/scipy,WillieMaddox/scipy,Shaswat27/scipy,futurulus/scipy,e-q/scipy,WarrenWeckesser/scipy,zxsted/scipy,surhudm/scipy,Shaswat27/scipy,larsmans/scipy,e-q/scipy,gdooper/scipy,Eric89GXL/scipy,vanpact/scipy,maciejkula/scipy,ndchorley/scipy,pnedunuri/scipy,felipebetancur/scipy,Newman101/scipy,maniteja123/scipy,jonycgn/scipy,trankmichael/scipy,pizzathief/scipy,juliantaylor/scipy,mdhaber/scipy,behzadnouri/scipy,scipy/scipy,lhilt/scipy,pnedunuri/scipy,giorgiop/scipy,larsmans/scipy,fredrikw/scipy,ales-erjavec/scipy,aeklant/scipy,matthewalbani/scipy,jakevdp/scipy,jsilter/scipy,dch312/scipy,vhaasteren/scipy,pschella/scipy,josephcslater/scipy,anielsen001/scipy,petebachant/scipy,dch312/scipy,jjhelmus/scipy,zerothi/scipy,e-q/scipy,larsmans/scipy,minhlongdo/scipy,vberaudi/scipy,haudren/scipy,Gillu13/scipy,matthew-brett/scipy,mdhaber/scipy,sargas/scipy,josephcslater/scipy,zerothi/scipy,ilayn/scipy,sriki18/scipy,ChanderG/scipy,larsmans/scipy,raoulbq/scipy,andyfaff/scipy,Dapid/scipy,pbrod/scipy,Kamp9/scipy,newemailjdm/scipy,raoulbq/scipy,mgaitan/scipy,mortonjt/scipy,maciejkula/scipy,dch312/scipy,vhaasteren/scipy,mgaitan/scipy,anntzer/scipy,mgaitan/scipy,mortonjt/scipy,mhogg/scipy,jor-/scipy,gertingold/scipy,sriki18/scipy,scipy/scipy,cpaulik/scipy,anntzer/scipy,futurulus/scipy,jonycgn/scipy,felipebetancur/scipy,anielsen001/scipy,aeklant/scipy,giorgiop/scipy,maniteja123/scipy,befelix/scipy,ogrisel/scipy,gfyoung/scipy,sonnyhu/scipy,giorgiop/scipy,gef756/scipy,hainm/scipy,hainm/scipy,fernand/scipy,zaxliu/scipy,Stefan-Endres/scipy,argriffing/scipy,pyramania/scipy,surhudm/scipy,tylerjereddy/scipy,matthewalbani/scipy,behzadnouri/scipy,Eric89GXL/scipy,lhilt/scipy,argriffing/scipy,mortonjt/scipy,dch312/scipy,richardotis/scipy,mingwpy/scipy,teoliphant/scipy,fernand/scipy,anielsen001/scipy,surhudm/scipy,zerothi/scipy,ales-erjavec/scipy,arokem/scipy,scipy/scipy,niknow/scipy,gef756/scipy,maniteja123/scipy,befelix/scipy,gfyoung/scipy,kalvdans/scipy,Eric89GXL/scipy,andyfaff/scipy,jsilter/scipy,nmayorov/scipy,pnedunuri/scipy,mikebenfield/scipy,FRidh/scipy,cpaulik/scipy,woodscn/scipy,Dapid/scipy,mortonjt/scipy,newemailjdm/scipy,perimosocordiae/scipy,jjhelmus/scipy,tylerjereddy/scipy,Dapid/scipy,jseabold/scipy,felipebetancur/scipy,pbrod/scipy,efiring/scipy,zxsted/scipy,anielsen001/scipy,jakevdp/scipy,befelix/scipy,tylerjereddy/scipy,arokem/scipy,Kamp9/scipy,apbard/scipy,mhogg/scipy,mhogg/scipy,andyfaff/scipy,jamestwebber/scipy,aeklant/scipy,befelix/scipy,rgommers/scipy,sauliusl/scipy,argriffing/scipy,lukauskas/scipy,zaxliu/scipy,ilayn/scipy,Dapid/scipy,kleskjr/scipy,sargas/scipy,Shaswat27/scipy,FRidh/scipy,newemailjdm/scipy,josephcslater/scipy,mdhaber/scipy,kalvdans/scipy,Stefan-Endres/scipy,mdhaber/scipy,mingwpy/scipy,fredrikw/scipy,mhogg/scipy,jseabold/scipy,mdhaber/scipy,WarrenWeckesser/scipy,raoulbq/scipy,Eric89GXL/scipy,ortylp/scipy,njwilson23/scipy,felipebetancur/scipy,Newman101/scipy,witcxc/scipy,e-q/scipy,ndchorley/scipy,lukauskas/scipy,mikebenfield/scipy,mdhaber/scipy,bkendzior/scipy,gef756/scipy,chatcannon/scipy,kleskjr/scipy,witcxc/scipy,nmayorov/scipy,mgaitan/scipy,juliantaylor/scipy,ogrisel/scipy,woodscn/scipy,Eric89GXL/scipy,efiring/scipy,nvoron23/scipy,WillieMaddox/scipy,efiring/scipy,minhlongdo/scipy,petebachant/scipy,maciejkula/scipy,Newman101/scipy,aeklant/scipy,jamestwebber/scipy,endolith/scipy,endolith/scipy,argriffing/scipy,arokem/scipy,jonycgn/scipy,Shaswat27/scipy,WillieMaddox/scipy,jonycgn/scipy,jsilter/scipy,befelix/scipy,richardotis/scipy,pbrod/scipy,kleskjr/scipy,aman-iitj/scipy,WarrenWeckesser/scipy,tylerjereddy/scipy,andim/scipy,Shaswat27/scipy,efiring/scipy,felipebetancur/scipy,gef756/scipy,aarchiba/scipy,tylerjereddy/scipy,fredrikw/scipy,jseabold/scipy,sauliusl/scipy,ndchorley/scipy,jseabold/scipy,jakevdp/scipy,anielsen001/scipy,pnedunuri/scipy,jamestwebber/scipy,Dapid/scipy,rgommers/scipy,cpaulik/scipy,vhaasteren/scipy,dominicelse/scipy,mtrbean/scipy,minhlongdo/scipy,arokem/scipy,gertingold/scipy,petebachant/scipy,hainm/scipy,sonnyhu/scipy,sargas/scipy,vanpact/scipy,Stefan-Endres/scipy,sauliusl/scipy,jonycgn/scipy,grlee77/scipy,lukauskas/scipy,teoliphant/scipy,giorgiop/scipy,njwilson23/scipy,piyush0609/scipy,anntzer/scipy,ales-erjavec/scipy,Kamp9/scipy,gertingold/scipy,nonhermitian/scipy,raoulbq/scipy,zaxliu/scipy,cpaulik/scipy,pnedunuri/scipy,Gillu13/scipy,niknow/scipy,njwilson23/scipy,Gillu13/scipy,surhudm/scipy,scipy/scipy,vigna/scipy,lhilt/scipy,haudren/scipy,sonnyhu/scipy,minhlongdo/scipy,perimosocordiae/scipy,juliantaylor/scipy,apbard/scipy,mtrbean/scipy,mikebenfield/scipy,dominicelse/scipy,sauliusl/scipy,mhogg/scipy,aarchiba/scipy,mingwpy/scipy,perimosocordiae/scipy,surhudm/scipy,jor-/scipy,hainm/scipy,raoulbq/scipy,grlee77/scipy,lhilt/scipy,rmcgibbo/scipy,zerothi/scipy,richardotis/scipy,zxsted/scipy,ChanderG/scipy,perimosocordiae/scipy,behzadnouri/scipy,Newman101/scipy,nonhermitian/scipy,jamestwebber/scipy,grlee77/scipy,vigna/scipy,ndchorley/scipy,Newman101/scipy,andim/scipy,aman-iitj/scipy,trankmichael/scipy,perimosocordiae/scipy,niknow/scipy,vanpact/scipy,aman-iitj/scipy,mtrbean/scipy,jamestwebber/scipy,sriki18/scipy,WillieMaddox/scipy,maniteja123/scipy,mtrbean/scipy,behzadnouri/scipy,aarchiba/scipy,minhlongdo/scipy,behzadnouri/scipy,pbrod/scipy,kleskjr/scipy,apbard/scipy,sargas/scipy,person142/scipy,rmcgibbo/scipy,ales-erjavec/scipy,Srisai85/scipy,vanpact/scipy,pschella/scipy,chatcannon/scipy,fredrikw/scipy,dch312/scipy,mortada/scipy,futurulus/scipy,endolith/scipy,scipy/scipy,argriffing/scipy,fernand/scipy,ChanderG/scipy,chatcannon/scipy,gertingold/scipy,nvoron23/scipy,piyush0609/scipy,ndchorley/scipy,fredrikw/scipy,vberaudi/scipy,jsilter/scipy,cpaulik/scipy,person142/scipy,Stefan-Endres/scipy,haudren/scipy,ortylp/scipy,andyfaff/scipy,Srisai85/scipy,arokem/scipy,jakevdp/scipy,larsmans/scipy,pnedunuri/scipy,mortada/scipy,trankmichael/scipy,rmcgibbo/scipy,fernand/scipy,nonhermitian/scipy,andim/scipy,endolith/scipy,njwilson23/scipy,grlee77/scipy,jjhelmus/scipy,matthew-brett/scipy,cpaulik/scipy,witcxc/scipy,njwilson23/scipy,sonnyhu/scipy,piyush0609/scipy,Gillu13/scipy,sonnyhu/scipy,vberaudi/scipy,zaxliu/scipy,pizzathief/scipy,Dapid/scipy,fernand/scipy,futurulus/scipy,mgaitan/scipy,richardotis/scipy,vhaasteren/scipy,matthewalbani/scipy,mortada/scipy,ortylp/scipy,pyramania/scipy,grlee77/scipy,WarrenWeckesser/scipy,gdooper/scipy,aman-iitj/scipy,Stefan-Endres/scipy,piyush0609/scipy,gfyoung/scipy,vigna/scipy,zerothi/scipy,mortada/scipy,woodscn/scipy,person142/scipy,witcxc/scipy,zxsted/scipy,ChanderG/scipy,Newman101/scipy,person142/scipy,matthew-brett/scipy,felipebetancur/scipy,FRidh/scipy,maniteja123/scipy,e-q/scipy,endolith/scipy,FRidh/scipy,WarrenWeckesser/scipy,josephcslater/scipy,pyramania/scipy,chatcannon/scipy,njwilson23/scipy,futurulus/scipy,chatcannon/scipy,petebachant/scipy,ogrisel/scipy,Kamp9/scipy,lukauskas/scipy,mingwpy/scipy,niknow/scipy,vberaudi/scipy,dominicelse/scipy,rgommers/scipy,nvoron23/scipy,bkendzior/scipy,gdooper/scipy,andim/scipy,WillieMaddox/scipy,richardotis/scipy,ogrisel/scipy,bkendzior/scipy,giorgiop/scipy,trankmichael/scipy,sauliusl/scipy,sargas/scipy,ortylp/scipy,josephcslater/scipy,mikebenfield/scipy,newemailjdm/scipy,jakevdp/scipy,FRidh/scipy,matthewalbani/scipy,ilayn/scipy
6d08c13fbf42eb4251d3477a904ab6d8513620df
dataset.py
dataset.py
from scrapy.item import Item, Field class DatasetItem(Item): name = Field() frequency = Field()
from scrapy.item import Item, Field class DatasetItem(Item): url = Field() name = Field() frequency = Field()
Add url field to Dataset web item
Add url field to Dataset web item
Python
mit
MaxLikelihood/CODE
b7a24dca6b52d8924f59dc0e8ecd8e25cac998a2
common/djangoapps/enrollment/urls.py
common/djangoapps/enrollment/urls.py
""" URLs for the Enrollment API """ from django.conf import settings from django.conf.urls import patterns, url from .views import ( EnrollmentView, EnrollmentListView, EnrollmentCourseDetailView ) urlpatterns = patterns( 'enrollment.views', url( r'^enrollment/{username},{course_key}$'.format( username=settings.USERNAME_PATTERN, course_key=settings.COURSE_ID_PATTERN ), EnrollmentView.as_view(), name='courseenrollment' ), url( r'^enrollment/{course_key}$'.format(course_key=settings.COURSE_ID_PATTERN), EnrollmentView.as_view(), name='courseenrollment' ), url(r'^enrollment$', EnrollmentListView.as_view(), name='courseenrollments'), url( r'^course/{course_key}$'.format(course_key=settings.COURSE_ID_PATTERN), EnrollmentCourseDetailView.as_view(), name='courseenrollmentdetails' ), )
""" URLs for the Enrollment API """ from django.conf import settings from django.conf.urls import patterns, url from .views import ( EnrollmentView, EnrollmentListView, EnrollmentCourseDetailView ) urlpatterns = patterns( 'enrollment.views', url( r'^enrollment/{username},{course_key}/$'.format( username=settings.USERNAME_PATTERN, course_key=settings.COURSE_ID_PATTERN ), EnrollmentView.as_view(), name='courseenrollment' ), url( r'^enrollment/{course_key}/$'.format(course_key=settings.COURSE_ID_PATTERN), EnrollmentView.as_view(), name='courseenrollment' ), url(r'^enrollment$', EnrollmentListView.as_view(), name='courseenrollments'), url( r'^course/{course_key}/$'.format(course_key=settings.COURSE_ID_PATTERN), EnrollmentCourseDetailView.as_view(), name='courseenrollmentdetails' ), )
Add options trailing slashes to the Enrollment API.
Add options trailing slashes to the Enrollment API. This allows the edX REST API Client to perform a sucessful GET against this API, since Slumber (which our client is based off of) appends the trailing slash by default.
Python
agpl-3.0
zhenzhai/edx-platform,zhenzhai/edx-platform,zhenzhai/edx-platform,zhenzhai/edx-platform,zhenzhai/edx-platform
62317424b7e318ac9c59aecc768a4487788bd179
content/test/gpu/gpu_tests/pixel_expectations.py
content/test/gpu/gpu_tests/pixel_expectations.py
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from gpu_test_expectations import GpuTestExpectations # See the GpuTestExpectations class for documentation. class PixelExpectations(GpuTestExpectations): def SetExpectations(self): # Sample Usage: # self.Fail('Pixel.Canvas2DRedBox', # ['mac', 'amd', ('nvidia', 0x1234)], bug=123) self.Fail('Pixel.Canvas2DRedBox', [ 'linux', ('nvidia', 0x104a)], bug=511580) self.Fail('Pixel.CSS3DBlueBox', [ 'linux', ('nvidia', 0x104a)], bug=511580) self.Fail('Pixel.WebGLGreenTriangle', [ 'linux', ('nvidia', 0x104a)], bug=511580) pass
# Copyright 2014 The Chromium Authors. All rights reserved. # Use of this source code is governed by a BSD-style license that can be # found in the LICENSE file. from gpu_test_expectations import GpuTestExpectations # See the GpuTestExpectations class for documentation. class PixelExpectations(GpuTestExpectations): def SetExpectations(self): # Sample Usage: # self.Fail('Pixel.Canvas2DRedBox', # ['mac', 'amd', ('nvidia', 0x1234)], bug=123) self.Fail('Pixel.Canvas2DRedBox', bug=511580) self.Fail('Pixel.CSS3DBlueBox', bug=511580) self.Fail('Pixel.WebGLGreenTriangle', bug=511580) pass
Mark pixel tests as failing on all platform
Mark pixel tests as failing on all platform BUG=511580 [email protected] Review URL: https://codereview.chromium.org/1245243003 Cr-Commit-Position: 972c6d2dc6dd5efdad1377c0d224e03eb8f276f7@{#340191}
Python
bsd-3-clause
lihui7115/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,lihui7115/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,CapOM/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend,ltilve/ChromiumGStreamerBackend
b5006a2820051e00c9fe4f5efe43e90129c12b4d
troposphere/cloudtrail.py
troposphere/cloudtrail.py
from . import AWSObject, AWSProperty, Tags from .validators import boolean class DataResource(AWSProperty): props = { "Type": (str, True), "Values": ([str], False), } class EventSelector(AWSProperty): props = { "DataResources": ([DataResource], False), "IncludeManagementEvents": (boolean, False), "ReadWriteType": (str, False), } class Trail(AWSObject): resource_type = "AWS::CloudTrail::Trail" props = { "CloudWatchLogsLogGroupArn": (str, False), "CloudWatchLogsRoleArn": (str, False), "EnableLogFileValidation": (boolean, False), "EventSelectors": ([EventSelector], False), "IncludeGlobalServiceEvents": (boolean, False), "IsLogging": (boolean, True), "IsMultiRegionTrail": (boolean, False), "KMSKeyId": (str, False), "S3BucketName": (str, True), "S3KeyPrefix": (str, False), "SnsTopicName": (str, False), "Tags": (Tags, False), "TrailName": (str, False), }
from . import AWSObject, AWSProperty, Tags from .validators import boolean class DataResource(AWSProperty): props = { "Type": (str, True), "Values": ([str], False), } class EventSelector(AWSProperty): props = { "DataResources": ([DataResource], False), "ExcludeManagementEventSources": ([str], False), "IncludeManagementEvents": (boolean, False), "ReadWriteType": (str, False), } class InsightSelector(AWSProperty): props = { "InsightType": (str, False), } class Trail(AWSObject): resource_type = "AWS::CloudTrail::Trail" props = { "CloudWatchLogsLogGroupArn": (str, False), "CloudWatchLogsRoleArn": (str, False), "EnableLogFileValidation": (boolean, False), "EventSelectors": ([EventSelector], False), "IncludeGlobalServiceEvents": (boolean, False), "InsightSelectors": ([InsightSelector], False), "IsLogging": (boolean, True), "IsMultiRegionTrail": (boolean, False), "IsOrganizationTrail": (boolean, False), "KMSKeyId": (str, False), "S3BucketName": (str, True), "S3KeyPrefix": (str, False), "SnsTopicName": (str, False), "Tags": (Tags, False), "TrailName": (str, False), }
Update Cloudtrail per 2021-09-10 changes
Update Cloudtrail per 2021-09-10 changes
Python
bsd-2-clause
cloudtools/troposphere,cloudtools/troposphere
fddd44624f1c8ff6f66a2f33cafe908a5853389d
glaciercmd/command_delete_archive_from_vault.py
glaciercmd/command_delete_archive_from_vault.py
import boto from boto.glacier.exceptions import UnexpectedHTTPResponseError class CommandDeleteArchiveFromVault(object): def execute(self, args, config): glacier_connection = boto.connect_glacier(aws_access_key_id=config.get('configuration', 'aws_key'), aws_secret_access_key=config.get('configuration', 'aws_secret')) try: vault = glacier_connection.get_vault(args[4]) except: vault = None if vault is None: print "Vault named '{}' does not exist.".format(args[4]) else: try: vault.delete_archive(args[2]) print "Archive deleted: '{}'".format(args[2]) except UnexpectedHTTPResponseError as error: print "Archive can not be deleted:\n\t {}".format(error) def accept(self, args): return len(args) >= 4 and args[0] == 'delete' and args[1] == 'archive' and args[3] == 'from' def help(self): return "delete archive <archive name> from <vault name>" def command_init(): return CommandDeleteArchiveFromVault()
import boto from boto.glacier.exceptions import UnexpectedHTTPResponseError from boto.dynamodb2.table import Table from boto.dynamodb2.layer1 import DynamoDBConnection class CommandDeleteArchiveFromVault(object): def execute(self, args, config): glacier_connection = boto.connect_glacier(aws_access_key_id=config.get('configuration', 'aws_key'), aws_secret_access_key=config.get('configuration', 'aws_secret')) try: vault = glacier_connection.get_vault(args[4]) except: vault = None if vault is None: print "Vault named '{}' does not exist.".format(args[4]) else: try: vault.delete_archive(args[2]) dynamo_connection=DynamoDBConnection(aws_access_key_id=config.get('configuration', 'aws_key'), aws_secret_access_key=config.get('configuration', 'aws_secret')) archive_table = Table(config.get('configuration', 'dynamodb_table'), connection=dynamo_connection) archive_table.delete_item(archive_id=args[2]) print "Archive deleted: '{}'".format(args[2]) except UnexpectedHTTPResponseError as error: print "Archive can not be deleted:\n\t {}".format(error) def accept(self, args): return len(args) >= 4 and args[0] == 'delete' and args[1] == 'archive' and args[3] == 'from' def help(self): return "delete archive <archive name> from <vault name>" def command_init(): return CommandDeleteArchiveFromVault()
Clean up dynamodb table when deleting an archive
Clean up dynamodb table when deleting an archive
Python
mit
carsonmcdonald/glacier-cmd
053d6a2ca13b1f36a02fa3223092a10af35f6579
erpnext/patches/v10_0/item_barcode_childtable_migrate.py
erpnext/patches/v10_0/item_barcode_childtable_migrate.py
# Copyright (c) 2017, Frappe and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals import frappe def execute(): items_barcode = frappe.get_all('Item', ['name', 'barcode'], { 'barcode': ('!=', '') }) frappe.reload_doc("stock", "doctype", "item") frappe.reload_doc("stock", "doctype", "item_barcode") for item in items_barcode: barcode = item.barcode.strip() if barcode and '<' not in barcode: try: frappe.get_doc({ 'idx': 0, 'doctype': 'Item Barcode', 'barcode': barcode, 'parenttype': 'Item', 'parent': item.name, 'parentfield': 'barcodes' }).insert() except frappe.DuplicateEntryError: continue
# Copyright (c) 2017, Frappe and Contributors # License: GNU General Public License v3. See license.txt from __future__ import unicode_literals import frappe def execute(): frappe.reload_doc("stock", "doctype", "item_barcode") items_barcode = frappe.get_all('Item', ['name', 'barcode'], { 'barcode': ('!=', '') }) frappe.reload_doc("stock", "doctype", "item") for item in items_barcode: barcode = item.barcode.strip() if barcode and '<' not in barcode: try: frappe.get_doc({ 'idx': 0, 'doctype': 'Item Barcode', 'barcode': barcode, 'parenttype': 'Item', 'parent': item.name, 'parentfield': 'barcodes' }).insert() except frappe.DuplicateEntryError: continue
Move reload doc before get query
Move reload doc before get query
Python
agpl-3.0
gsnbng/erpnext,gsnbng/erpnext,gsnbng/erpnext,gsnbng/erpnext
16b9f48c2b6548a16e1c34a57c103b325fae381d
farmers_api/farmers/models.py
farmers_api/farmers/models.py
from django.db import models from django.utils.translation import ugettext_lazy as _ class Farmer(models.Model): first_name = models.CharField(_('first name'), max_length=50) surname = models.CharField(_('surname'), max_length=50) town = models.CharField(_('town'), max_length=50, db_index=True) class Meta: verbose_name = _('farmer') verbose_name_plural = _('farmers') def __str__(self): return self.get_full_name() def get_full_name(self): return '%s %s' % (self.first_name, self.surname) def get_short_name(self): return '%s. %s' % (self.first_name[:1], self_surname)
from django.db import models from django.utils.translation import ugettext_lazy as _ class Farmer(models.Model): first_name = models.CharField(_('first name'), max_length=50) surname = models.CharField(_('surname'), max_length=50) town = models.CharField(_('town'), max_length=50, db_index=True) class Meta: verbose_name = _('farmer') verbose_name_plural = _('farmers') def __str__(self): return self.get_full_name() def get_full_name(self): return '%s %s' % (self.first_name, self.surname) def get_short_name(self): return '%s. %s' % (self.first_name[:1], self.surname)
Repair bug in the Farmer model
Repair bug in the Farmer model
Python
bsd-2-clause
tm-kn/farmers-api
70f9275d7b87d56ae560a2ff60c3eed3469739af
edx_rest_api_client/tests/mixins.py
edx_rest_api_client/tests/mixins.py
import responses class AuthenticationTestMixin(object): """ Mixin for testing authentication. """ def setUp(self): super(AuthenticationTestMixin, self).setUp() responses.reset() def _mock_auth_api(self, url, status, body=None): body = body or {} responses.add( responses.POST, url, status=status, json=body, content_type='application/json' )
import responses class AuthenticationTestMixin: """ Mixin for testing authentication. """ def setUp(self): super(AuthenticationTestMixin, self).setUp() responses.reset() def _mock_auth_api(self, url, status, body=None): body = body or {} responses.add( responses.POST, url, status=status, json=body, content_type='application/json' )
Fix new lint errors now that we've dropped python 2 support.
Fix new lint errors now that we've dropped python 2 support.
Python
apache-2.0
edx/ecommerce-api-client,edx/edx-rest-api-client
a2efdbc7c790df31f511d9a347774a961132d565
txircd/modules/cmode_l.py
txircd/modules/cmode_l.py
from twisted.words.protocols import irc from txircd.modbase import Mode class LimitMode(Mode): def checkSet(self, user, target, param): intParam = int(param) if str(intParam) != param: return [False, param] return [(intParam >= 0), param] def checkPermission(self, user, cmd, data): if cmd != "JOIN": return data targetChannels = data["targetchan"] keys = data["keys"] removeChannels = [] for channel in targetChannels: if "l" in channel.mode and len(channel.users) >= int(channel.mode["l"]): user.sendMessage(irc.ERR_CHANNELISFULL, channel.name, ":Cannot join channel (Channel is full)") removeChannels.append(channel) for channel in removeChannels: index = targetChannels.index(channel) targetChannels.pop(index) keys.pop(index) data["targetchan"] = targetChannels data["keys"] = keys return data class Spawner(object): def __init__(self, ircd): self.ircd = ircd def spawn(self): return { "modes": { "cpl": LimitMode() }, "common": True } def cleanup(self): self.ircd.removeMode("cpl")
from twisted.words.protocols import irc from txircd.modbase import Mode class LimitMode(Mode): def checkSet(self, user, target, param): try: intParam = int(param) except ValueError: return [False, param] if str(intParam) != param: return [False, param] return [(intParam > 0), param] def checkPermission(self, user, cmd, data): if cmd != "JOIN": return data targetChannels = data["targetchan"] keys = data["keys"] removeChannels = [] for channel in targetChannels: if "l" in channel.mode and len(channel.users) >= int(channel.mode["l"]): user.sendMessage(irc.ERR_CHANNELISFULL, channel.name, ":Cannot join channel (Channel is full)") removeChannels.append(channel) for channel in removeChannels: index = targetChannels.index(channel) targetChannels.pop(index) keys.pop(index) data["targetchan"] = targetChannels data["keys"] = keys return data class Spawner(object): def __init__(self, ircd): self.ircd = ircd def spawn(self): return { "modes": { "cpl": LimitMode() }, "common": True } def cleanup(self): self.ircd.removeMode("cpl")
Fix checking of limit parameter
Fix checking of limit parameter
Python
bsd-3-clause
DesertBus/txircd,Heufneutje/txircd,ElementalAlchemist/txircd
380331a54ae09a54e458b30a0fb6a459faa76f37
emission/analysis/point_features.py
emission/analysis/point_features.py
# Standard imports import math import logging import numpy as np import emission.core.common as ec import emission.analysis.section_features as sf def calDistance(point1, point2): return ec.calDistance([point1.longitude, point1.latitude], [point2.longitude, point2.latitude]) def calHeading(point1, point2): return sf.calHeading([point1.longitude, point1.latitude], [point2.longitude, point2.latitude]) def calHC(point1, point2, point3): return sf.calHC([point1.longitude, point1.latitude], [point2.longitude, point2.latitude], [point3.longitude, point3.latitude]) def calSpeed(point1, point2): distanceDelta = calDistance(point1, point2) timeDelta = point2.mTime - point1.mTime # print "Distance delta = %s and time delta = %s" % (distanceDelta, timeDelta) # assert(timeDelta != 0) if (timeDelta == 0): logging.debug("timeDelta = 0, distanceDelta = %s, returning speed = 0") assert(distanceDelta < 0.01) return 0 # TODO: Once we perform the conversions from ms to secs as part of the # usercache -> timeseries switch, we need to remove this division by 1000 return distanceDelta/(float(timeDelta)/1000)
# Standard imports import math import logging import numpy as np import emission.core.common as ec import emission.analysis.section_features as sf def calDistance(point1, point2): return ec.calDistance([point1.longitude, point1.latitude], [point2.longitude, point2.latitude]) def calHeading(point1, point2): return sf.calHeading([point1.longitude, point1.latitude], [point2.longitude, point2.latitude]) def calHC(point1, point2, point3): return sf.calHC([point1.longitude, point1.latitude], [point2.longitude, point2.latitude], [point3.longitude, point3.latitude]) def calSpeed(point1, point2): distanceDelta = calDistance(point1, point2) timeDelta = point2.ts - point1.ts # print "Distance delta = %s and time delta = %s" % (distanceDelta, timeDelta) # assert(timeDelta != 0) if (timeDelta == 0): logging.debug("timeDelta = 0, distanceDelta = %s, returning speed = 0") assert(distanceDelta < 0.01) return 0 return distanceDelta/timeDelta
Change the feature calculation to match the new unified format
Change the feature calculation to match the new unified format - the timestamps are now in seconds, so no need to divide them - the field is called ts, not mTime
Python
bsd-3-clause
e-mission/e-mission-server,e-mission/e-mission-server,shankari/e-mission-server,sunil07t/e-mission-server,joshzarrabi/e-mission-server,e-mission/e-mission-server,shankari/e-mission-server,joshzarrabi/e-mission-server,joshzarrabi/e-mission-server,yw374cornell/e-mission-server,sunil07t/e-mission-server,sunil07t/e-mission-server,shankari/e-mission-server,yw374cornell/e-mission-server,joshzarrabi/e-mission-server,yw374cornell/e-mission-server,shankari/e-mission-server,e-mission/e-mission-server,sunil07t/e-mission-server,yw374cornell/e-mission-server
4de5050deda6c73fd9812a5e53938fea11e0b2cc
tests/unit/minion_test.py
tests/unit/minion_test.py
# -*- coding: utf-8 -*- ''' :codeauthor: :email:`Mike Place <[email protected]>` ''' # Import Salt Testing libs from salttesting import TestCase, skipIf from salttesting.helpers import ensure_in_syspath from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch from salt import minion from salt.exceptions import SaltSystemExit ensure_in_syspath('../') __opts__ = {} @skipIf(NO_MOCK, NO_MOCK_REASON) class MinionTestCase(TestCase): def test_invalid_master_address(self): with patch.dict(__opts__, {'ipv6': False, 'master': float('127.0'), 'master_port': '4555', 'retry_dns': False}): self.assertRaises(SaltSystemExit, minion.resolve_dns, __opts__) if __name__ == '__main__': from integration import run_tests run_tests(MinionTestCase, needs_daemon=False)
# -*- coding: utf-8 -*- ''' :codeauthor: :email:`Mike Place <[email protected]>` ''' # Import python libs import os # Import Salt Testing libs from salttesting import TestCase, skipIf from salttesting.helpers import ensure_in_syspath from salttesting.mock import NO_MOCK, NO_MOCK_REASON, patch # Import salt libs from salt import minion from salt.exceptions import SaltSystemExit import salt.syspaths ensure_in_syspath('../') __opts__ = {} @skipIf(NO_MOCK, NO_MOCK_REASON) class MinionTestCase(TestCase): def test_invalid_master_address(self): with patch.dict(__opts__, {'ipv6': False, 'master': float('127.0'), 'master_port': '4555', 'retry_dns': False}): self.assertRaises(SaltSystemExit, minion.resolve_dns, __opts__) def test_sock_path_len(self): ''' This tests whether or not a larger hash causes the sock path to exceed the system's max sock path length. See the below link for more information. https://github.com/saltstack/salt/issues/12172#issuecomment-43903643 ''' opts = { 'id': 'salt-testing', 'hash_type': 'sha512', 'sock_dir': os.path.join(salt.syspaths.SOCK_DIR, 'minion') } with patch.dict(__opts__, opts): testminion = minion.MinionBase(__opts__) try: testminion._prepare_minion_event_system() result = True except SaltSystemExit: result = False self.assertTrue(result) if __name__ == '__main__': from integration import run_tests run_tests(MinionTestCase, needs_daemon=False)
Add test for sock path length
Add test for sock path length
Python
apache-2.0
saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt,saltstack/salt
1fc6eb9ccc9789e2717898108f286adf5b351031
payments/management/commands/init_plans.py
payments/management/commands/init_plans.py
from django.conf import settings from django.core.management.base import BaseCommand import stripe class Command(BaseCommand): help = "Make sure your Stripe account has the plans" def handle(self, *args, **options): stripe.api_key = settings.STRIPE_SECRET_KEY for plan in settings.PAYMENTS_PLANS: if settings.PAYMENTS_PLANS[plan].get("stripe_plan_id"): stripe.Plan.create( amount=100 * settings.PAYMENTS_PLANS[plan]["price"], interval=settings.PAYMENTS_PLANS[plan]["interval"], name=settings.PAYMENTS_PLANS[plan]["name"], currency=settings.PAYMENTS_PLANS[plan]["currency"], id=settings.PAYMENTS_PLANS[plan].get("stripe_plan_id") ) print "Plan created for {0}".format(plan)
from django.conf import settings from django.core.management.base import BaseCommand import stripe class Command(BaseCommand): help = "Make sure your Stripe account has the plans" def handle(self, *args, **options): stripe.api_key = settings.STRIPE_SECRET_KEY for plan in settings.PAYMENTS_PLANS: if settings.PAYMENTS_PLANS[plan].get("stripe_plan_id"): stripe.Plan.create( amount=int(100 * settings.PAYMENTS_PLANS[plan]["price"]), interval=settings.PAYMENTS_PLANS[plan]["interval"], name=settings.PAYMENTS_PLANS[plan]["name"], currency=settings.PAYMENTS_PLANS[plan]["currency"], id=settings.PAYMENTS_PLANS[plan].get("stripe_plan_id") ) print "Plan created for {0}".format(plan)
Make sure this value is always an integer
Make sure this value is always an integer
Python
bsd-3-clause
wahuneke/django-stripe-payments,aibon/django-stripe-payments,boxysean/django-stripe-payments,crehana/django-stripe-payments,adi-li/django-stripe-payments,wahuneke/django-stripe-payments,jawed123/django-stripe-payments,jamespacileo/django-stripe-payments,ZeevG/django-stripe-payments,ZeevG/django-stripe-payments,crehana/django-stripe-payments,grue/django-stripe-payments,jawed123/django-stripe-payments,alexhayes/django-stripe-payments,aibon/django-stripe-payments,jamespacileo/django-stripe-payments,grue/django-stripe-payments,alexhayes/django-stripe-payments,boxysean/django-stripe-payments,pinax/django-stripe-payments,wahuneke/django-stripe-payments,adi-li/django-stripe-payments
27ab83010f7cc8308debfec16fab38544a9c7ce7
running.py
running.py
import tcxparser from configparser import ConfigParser from datetime import datetime import urllib.request import dateutil.parser t = '1984-06-02T19:05:00.000Z' # Darksky weather API # Create config file manually parser = ConfigParser() parser.read('slowburn.config', encoding='utf-8') darksky_key = parser.get('darksky', 'key') tcx = tcxparser.TCXParser('gps_logs/2017-06-15_Running.tcx') run_time = tcx.completed_at def convert_time_to_unix(time): parsed_time = dateutil.parser.parse(time) time_in_unix = parsed_time.strftime('%s') return time_in_unix unix_run_time = convert_time_to_unix(run_time) darksky_request = urllib.request.urlopen("https://api.darksky.net/forecast/" + darksky_key + "/" + str(tcx.latitude) + "," + str(tcx.longitude) + "," + unix_run_time + "?exclude=currently,flags").read() print(darksky_request) class getWeather: def __init__(self, date, time): self.date = date self.time = time def goodbye(self, date): print("my name is " + date)
import tcxparser from configparser import ConfigParser from datetime import datetime import urllib.request import dateutil.parser import json # Darksky weather API # Create config file manually parser = ConfigParser() parser.read('slowburn.config', encoding='utf-8') darksky_key = parser.get('darksky', 'key') tcx = tcxparser.TCXParser('gps_logs/2017-06-15_Running.tcx') run_time = tcx.completed_at def convert_time_to_unix(time): parsed_time = dateutil.parser.parse(time) time_in_unix = parsed_time.strftime('%s') return time_in_unix unix_run_time = convert_time_to_unix(run_time) darksky_request = urllib.request.urlopen("https://api.darksky.net/forecast/" + darksky_key + "/" + str(tcx.latitude) + "," + str(tcx.longitude) + "," + unix_run_time + "?exclude=currently,flags").read() # Decode JSON darksky_json = json.loads(darksky_request.decode('utf-8')) for i in darksky_json['hourly']['data']: print(i['temperature']) class getWeather: def __init__(self, date, time): self.date = date self.time = time def goodbye(self, date): print("my name is " + date)
Print all hourly temperatures from run date
Print all hourly temperatures from run date
Python
mit
briansuhr/slowburn
e379aa75690d5bacc1d0bdec325ed4c16cf1a183
lims/permissions/views.py
lims/permissions/views.py
from django.contrib.auth.models import Permission from rest_framework import viewsets from .serializers import PermissionSerializer class PermissionViewSet(viewsets.ReadOnlyModelViewSet): queryset = Permission.objects.all() serializer_class = PermissionSerializer
from django.contrib.auth.models import Permission from rest_framework import viewsets from .serializers import PermissionSerializer class PermissionViewSet(viewsets.ReadOnlyModelViewSet): queryset = Permission.objects.all() serializer_class = PermissionSerializer search_fields = ('name',)
Add search functionality to permissions endpoint
Add search functionality to permissions endpoint
Python
mit
GETLIMS/LIMS-Backend,GETLIMS/LIMS-Backend
00922099d6abb03a0dbcca19781eb586d367eab0
skimage/measure/__init__.py
skimage/measure/__init__.py
from .find_contours import find_contours from ._regionprops import regionprops from .find_contours import find_contours from ._structural_similarity import ssim
from .find_contours import find_contours from ._regionprops import regionprops from ._structural_similarity import ssim
Remove double import of find contours.
BUG: Remove double import of find contours.
Python
bsd-3-clause
robintw/scikit-image,WarrenWeckesser/scikits-image,ofgulban/scikit-image,ajaybhat/scikit-image,rjeli/scikit-image,SamHames/scikit-image,chintak/scikit-image,ofgulban/scikit-image,SamHames/scikit-image,dpshelio/scikit-image,chintak/scikit-image,rjeli/scikit-image,oew1v07/scikit-image,almarklein/scikit-image,pratapvardhan/scikit-image,bsipocz/scikit-image,ClinicalGraphics/scikit-image,vighneshbirodkar/scikit-image,michaelaye/scikit-image,michaelaye/scikit-image,jwiggins/scikit-image,pratapvardhan/scikit-image,keflavich/scikit-image,chriscrosscutler/scikit-image,Britefury/scikit-image,dpshelio/scikit-image,bennlich/scikit-image,bsipocz/scikit-image,blink1073/scikit-image,GaZ3ll3/scikit-image,paalge/scikit-image,almarklein/scikit-image,Hiyorimi/scikit-image,bennlich/scikit-image,Hiyorimi/scikit-image,emon10005/scikit-image,emmanuelle/scikits.image,vighneshbirodkar/scikit-image,ofgulban/scikit-image,almarklein/scikit-image,warmspringwinds/scikit-image,Midafi/scikit-image,youprofit/scikit-image,chintak/scikit-image,newville/scikit-image,Britefury/scikit-image,almarklein/scikit-image,juliusbierk/scikit-image,jwiggins/scikit-image,chriscrosscutler/scikit-image,michaelpacer/scikit-image,emmanuelle/scikits.image,juliusbierk/scikit-image,SamHames/scikit-image,robintw/scikit-image,chintak/scikit-image,WarrenWeckesser/scikits-image,Midafi/scikit-image,emmanuelle/scikits.image,vighneshbirodkar/scikit-image,newville/scikit-image,blink1073/scikit-image,michaelpacer/scikit-image,emmanuelle/scikits.image,oew1v07/scikit-image,emon10005/scikit-image,youprofit/scikit-image,ajaybhat/scikit-image,paalge/scikit-image,rjeli/scikit-image,warmspringwinds/scikit-image,paalge/scikit-image,keflavich/scikit-image,ClinicalGraphics/scikit-image,GaZ3ll3/scikit-image,SamHames/scikit-image
985cefd81472069240b074423a831fe6031d6887
website_sale_available/controllers/website_sale_available.py
website_sale_available/controllers/website_sale_available.py
# -*- coding: utf-8 -*- from openerp import http from openerp.http import request from openerp.addons.website_sale.controllers.main import website_sale class controller(website_sale): @http.route(['/shop/confirm_order'], type='http', auth="public", website=True) def confirm_order(self, **post): res = super(controller, self).confirm_order(**post) order = request.website.sale_get_order(context=request.context) if not all([ line.product_uom_qty <= line.product_id.virtual_available for line in order.order_line ]): return request.redirect("/shop/cart") return res
# -*- coding: utf-8 -*- from openerp import http from openerp.http import request from openerp.addons.website_sale.controllers.main import website_sale class controller(website_sale): @http.route(['/shop/confirm_order'], type='http', auth="public", website=True) def confirm_order(self, **post): res = super(controller, self).confirm_order(**post) order = request.website.sale_get_order(context=request.context) if not all([ line.product_uom_qty <= line.product_id.virtual_available for line in order.order_line if not line.is_delivery ]): return request.redirect("/shop/cart") return res
FIX sale_available integration with delivery
FIX sale_available integration with delivery
Python
mit
it-projects-llc/website-addons,it-projects-llc/website-addons,it-projects-llc/website-addons
1f409a2732886b6a77d348529e07e9f90fbfd8ba
conanfile.py
conanfile.py
from conans import ConanFile, CMake class CausalSetsExplorer(ConanFile): settings = "os", "compiler", "build_type", "arch" requires = "boost/1.67.0@conan/stable", "catch2/2.3.0@bincrafters/stable" generators = "cmake" default_options = "Boost:header_only=True" def build(self): cmake = CMake(self) cmake.verbose = True cmake.configure(args=["CMAKE_BUILD_TYPE=Release"]) cmake.build() def build_requirements(self): # AppVeyor already has modern CMake installed if self.settings.os != "Windows": self.build_requires("cmake_installer/3.11.3@conan/stable")
from conans import ConanFile, CMake class CausalSetsExplorer(ConanFile): settings = "os", "compiler", "build_type", "arch" requires = "boost/1.67.0@conan/stable", "catch2/2.2.2@bincrafters/stable" generators = "cmake" default_options = "Boost:header_only=True" def build(self): cmake = CMake(self) cmake.verbose = True cmake.configure(args=["CMAKE_BUILD_TYPE=Release"]) cmake.build() def build_requirements(self): # AppVeyor already has modern CMake installed if self.settings.os != "Windows": self.build_requires("cmake_installer/3.11.3@conan/stable")
Revert back to older Catch2, part 2
Revert back to older Catch2, part 2 Too quick on the commit button
Python
bsd-3-clause
acgetchell/causal-sets-explorer,acgetchell/causal-sets-explorer
31ee04b2eed6881a4f6642495545868f7c167a20
sipa/blueprints/hooks.py
sipa/blueprints/hooks.py
import logging from flask import current_app, request, abort from flask.blueprints import Blueprint from sipa.utils.git_utils import update_repo logger = logging.getLogger(__name__) bp_hooks = Blueprint('hooks', __name__, url_prefix='/hooks') @bp_hooks.route('/update-content', methods=['POST']) def content_hook(): auth_key = current_app.config.get('GIT_UPDATE_HOOK_TOKEN') if not auth_key: # no key configured (default) → feature not enabled abort(404) key = request.args.get('token') if not key: logger.debug("`update-content` called without Token", extra={'data': {'request_args': request.args}}) abort(401) if key != auth_key: logger.warning("`update-content` called with wrong Token", extra={'data': {'request_args': request.args, 'auth_key': auth_key}}) abort(403) logger.info("Update hook triggered. Fetching content.") reload_necessary = update_repo(current_app.config['FLATPAGES_ROOT']) if reload_necessary: try: import uwsgi except ImportError: logger.debug("UWSGI not present, skipping reload") pass else: logger.debug("Reloading UWSGI…") uwsgi.reload() # 204: No content # https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204 return "", 204
import logging from flask import current_app, request, abort from flask.blueprints import Blueprint from sipa.utils.git_utils import update_repo logger = logging.getLogger(__name__) bp_hooks = Blueprint('hooks', __name__, url_prefix='/hooks') @bp_hooks.route('/update-content', methods=['POST']) def content_hook(): auth_key = current_app.config.get('GIT_UPDATE_HOOK_TOKEN') if not auth_key: # no key configured (default) → feature not enabled abort(404) key = request.args.get('token') if not key: logger.debug("`update-content` called without Token", extra={'data': {'request_args': request.args}}) abort(401) if key != auth_key: logger.warning("`update-content` called with wrong Token", extra={'data': {'request_args': request.args, 'auth_key': auth_key}}) abort(403) logger.info("Update hook triggered. Fetching content.") reload_necessary = update_repo(current_app.config['FLATPAGES_ROOT']) if reload_necessary: try: import uwsgi except ImportError: logger.debug("UWSGI not present, skipping reload") pass else: logger.debug("Reloading UWSGI...") uwsgi.reload() # 204: No content # https://en.wikipedia.org/wiki/List_of_HTTP_status_codes#204 return "", 204
Use ascii in logging message
Use ascii in logging message
Python
mit
MarauderXtreme/sipa,agdsn/sipa,agdsn/sipa,agdsn/sipa,MarauderXtreme/sipa,lukasjuhrich/sipa,lukasjuhrich/sipa,lukasjuhrich/sipa,lukasjuhrich/sipa,agdsn/sipa,MarauderXtreme/sipa
3f26d3c53f4bff36ec05da7a51a026b7d3ba5517
tests/modules/test_atbash.py
tests/modules/test_atbash.py
"""Tests for the Caeser module""" import pycipher from lantern.modules import atbash def _test_atbash(plaintext, *fitness_functions, top_n=1): ciphertext = pycipher.Atbash().encipher(plaintext, keep_punct=True) decryption = atbash.decrypt(ciphertext) assert decryption == plaintext.upper() def test_decrypt(): """Test decryption""" assert atbash.decrypt("uozt{Yzybolm}") == "flag{Babylon}" def test_encrypt(): """Test encrypt""" assert ''.join(atbash.encrypt("flag{Babylon}")) == "uozt{Yzybolm}"
"""Tests for the Caeser module""" from lantern.modules import atbash def test_decrypt(): """Test decryption""" assert atbash.decrypt("uozt{Yzybolm}") == "flag{Babylon}" def test_encrypt(): """Test encryption""" assert ''.join(atbash.encrypt("flag{Babylon}")) == "uozt{Yzybolm}"
Remove unnecessary testing code from atbash
Remove unnecessary testing code from atbash
Python
mit
CameronLonsdale/lantern
2c7065f82a242e6f05eaefda4ec902ddf9d90037
tests/test_stanc_warnings.py
tests/test_stanc_warnings.py
"""Test that stanc warnings are visible.""" import contextlib import io import stan def test_stanc_no_warning() -> None: """No warnings.""" program_code = "parameters {real y;} model {y ~ normal(0,1);}" buffer = io.StringIO() with contextlib.redirect_stderr(buffer): stan.build(program_code=program_code) assert "warning" not in buffer.getvalue().lower() def test_stanc_warning() -> None: """Test that stanc warning is shown to user.""" # stanc prints warning: # assignment operator <- is deprecated in the Stan language; use = instead. program_code = """ parameters { real y; } model { real x; x <- 5; } """ buffer = io.StringIO() with contextlib.redirect_stderr(buffer): stan.build(program_code=program_code) assert "assignment operator <- is deprecated in the Stan language" in buffer.getvalue()
"""Test that stanc warnings are visible.""" import contextlib import io import stan def test_stanc_no_warning() -> None: """No warnings.""" program_code = "parameters {real y;} model {y ~ normal(0,1);}" buffer = io.StringIO() with contextlib.redirect_stderr(buffer): stan.build(program_code=program_code) assert "warning" not in buffer.getvalue().lower() def test_stanc_unused_warning() -> None: """Test that stanc warning is shown to user.""" program_code = """ parameters { real y; } model { real x; x = 5; } """ buffer = io.StringIO() with contextlib.redirect_stderr(buffer): stan.build(program_code=program_code) assert "The parameter y was declared but was not used in the density" in buffer.getvalue() def test_stanc_assignment_warning() -> None: """Test that stanc warning is shown to user.""" # stanc prints warning: # assignment operator <- is deprecated in the Stan language; use = instead. program_code = """ parameters { real y; } model { real x; x <- 5; y ~ normal(0,1); } """ buffer = io.StringIO() with contextlib.redirect_stderr(buffer): stan.build(program_code=program_code) assert "operator <- is deprecated in the Stan language and will be removed" in buffer.getvalue(), buffer.getvalue()
Update test for Stan 2.29
test: Update test for Stan 2.29
Python
isc
stan-dev/pystan,stan-dev/pystan
f668956fd37fa2fa0a0c82a8241671bf3cc306cb
tests/unit/moto_test_data.py
tests/unit/moto_test_data.py
""" These functions are written assuming the under a moto call stack. TODO add check is a fake bucket? """ import boto3 def pre_load_s3_data(bucket_name, prefix, region='us-east-1'): s3 = boto3.client('s3', region_name=region) res = s3.create_bucket(Bucket=bucket_name) default_kwargs = {"Body": b"Fake data for testing.", "Bucket": bucket_name} s3.put_object(Key=f"{prefix}/readme.txt", **default_kwargs) s3.put_object(Key=f"{prefix}/notes.md", **default_kwargs) # load items, 3 directories for i, _ in enumerate(range(500)): res = s3.put_object(Key=f"{prefix}/images/myimage{i}.tif", **default_kwargs) for i, _ in enumerate(range(400)): s3.put_object( Key=f"{prefix}/scripts/myscripts{i}.py", **default_kwargs ) for i, _ in enumerate(range(110)): s3.put_object( Key=f"{prefix}/scripts/subdir/otherscripts{i}.sh", **default_kwargs )
""" These functions are written assuming the under a moto call stack. TODO add check is a fake bucket? """ import boto3 def pre_load_s3_data(bucket_name, prefix, region='us-east-1'): s3 = boto3.client('s3', region_name=region) res = s3.create_bucket(Bucket=bucket_name) default_kwargs = {"Body": b"Fake data for testing.", "Bucket": bucket_name} s3.put_object(Key="{}/readme.txt".format(prefix), **default_kwargs) s3.put_object(Key="{}/notes.md".format(prefix), **default_kwargs) # load items, 3 directories for i, _ in enumerate(range(500)): res = s3.put_object(Key="{}/images/myimage{i}.tif".format(prefix), **default_kwargs) for i, _ in enumerate(range(400)): s3.put_object(Key="{}/scripts/myscripts{i}.py".format(prefix), **default_kwargs) for i, _ in enumerate(range(110)): s3.put_object( Key="{}/scripts/subdir/otherscripts{i}.sh".format(prefix), **default_kwargs)
Fix string using py3 only feature.
Fix string using py3 only feature.
Python
mit
DigitalGlobe/gbdxtools,DigitalGlobe/gbdxtools
03b685055037283279394d940602520c5ff7a817
email_log/models.py
email_log/models.py
from __future__ import unicode_literals from django.db import models from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ @python_2_unicode_compatible class Email(models.Model): """Model to store outgoing email information""" from_email = models.TextField(_("from e-mail")) recipients = models.TextField(_("recipients")) subject = models.TextField(_("subject")) body = models.TextField(_("body")) ok = models.BooleanField(_("ok"), default=False, db_index=True) date_sent = models.DateTimeField(_("date sent"), auto_now_add=True, db_index=True) def __str__(self): return "{s.recipients}: {s.subject}".format(s=self) class Meta: verbose_name = _("e-mail") verbose_name_plural = _("e-mails") ordering = ('-date_sent',)
from __future__ import unicode_literals from django.db import models from django.utils.encoding import python_2_unicode_compatible from django.utils.translation import ugettext_lazy as _ @python_2_unicode_compatible class Email(models.Model): """Model to store outgoing email information""" from_email = models.TextField(_("from e-mail")) recipients = models.TextField(_("recipients")) subject = models.TextField(_("subject")) body = models.TextField(_("body")) ok = models.BooleanField(_("ok"), default=False, db_index=True) date_sent = models.DateTimeField(_("date sent"), auto_now_add=True, db_index=True) def __str__(self): return "{s.recipients}: {s.subject}".format(s=self) class Meta: verbose_name = _("e-mail") verbose_name_plural = _("e-mails") ordering = ('-date_sent',)
Fix indentation problem and line length (PEP8)
Fix indentation problem and line length (PEP8)
Python
mit
treyhunner/django-email-log,treyhunner/django-email-log
9cbb73371db450599b7a3a964ab43f2f717b8bb7
connector/__manifest__.py
connector/__manifest__.py
# -*- coding: utf-8 -*- # Copyright 2013-2017 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) {'name': 'Connector', 'version': '10.0.1.0.0', 'author': 'Camptocamp,Openerp Connector Core Editors,' 'Odoo Community Association (OCA)', 'website': 'http://odoo-connector.com', 'license': 'AGPL-3', 'category': 'Generic Modules', 'depends': ['mail', 'queue_job', ], 'data': ['security/connector_security.xml', 'security/ir.model.access.csv', 'checkpoint/checkpoint_view.xml', 'connector_menu.xml', 'setting_view.xml', 'res_partner_view.xml', ], 'installable': True, 'application': True, }
# -*- coding: utf-8 -*- # Copyright 2013-2017 Camptocamp SA # License AGPL-3.0 or later (http://www.gnu.org/licenses/agpl.html) {'name': 'Connector', 'version': '10.0.1.0.0', 'author': 'Camptocamp,Openerp Connector Core Editors,' 'Odoo Community Association (OCA)', 'website': 'http://odoo-connector.com', 'license': 'AGPL-3', 'category': 'Generic Modules', 'depends': ['mail', 'queue_job', ], 'data': ['security/connector_security.xml', 'security/ir.model.access.csv', 'checkpoint/checkpoint_view.xml', 'connector_menu.xml', 'setting_view.xml', 'res_partner_view.xml', ], 'installable': True, }
Remove application flag, not an application
Remove application flag, not an application
Python
agpl-3.0
OCA/connector,OCA/connector
ad6bb5b787b4b959ff24c71122fc6f4d1a7e7ff9
cooltools/cli/__init__.py
cooltools/cli/__init__.py
# -*- coding: utf-8 -*- from __future__ import division, print_function import click from .. import __version__ # Monkey patch click.core._verify_python3_env = lambda: None CONTEXT_SETTINGS = { 'help_option_names': ['-h', '--help'], } @click.version_option(version=__version__) @click.group(context_settings=CONTEXT_SETTINGS) def cli(): pass from . import ( dump_cworld, diamond_insulation, compute_expected, compute_saddle, call_dots, )
# -*- coding: utf-8 -*- from __future__ import division, print_function import click import sys from .. import __version__ # Monkey patch click.core._verify_python3_env = lambda: None CONTEXT_SETTINGS = { 'help_option_names': ['-h', '--help'], } @click.version_option(version=__version__) @click.group(context_settings=CONTEXT_SETTINGS) @click.option( '--debug/--no-debug', help="Verbose logging", default=False) @click.option( '-pm', '--post-mortem', help="Post mortem debugging", is_flag=True, default=False) def cli(debug, post_mortem): """ Type -h or --help after any subcommand for more information. """ if debug: pass #logger.setLevel(logging.DEBUG) if post_mortem: import traceback try: import ipdb as pdb except ImportError: import pdb def _excepthook(exc_type, value, tb): traceback.print_exception(exc_type, value, tb) print() pdb.pm() sys.excepthook = _excepthook from . import ( dump_cworld, diamond_insulation, compute_expected, compute_saddle, call_dots, )
Add top-level cli debugging and verbosity options
Add top-level cli debugging and verbosity options
Python
mit
open2c/cooltools
efab6ea568c11411d901249d7660765cd987b532
examples/completion.py
examples/completion.py
import gtk from kiwi.ui.widgets.entry import Entry entry = Entry() entry.set_completion_strings(['apa', 'apapa', 'apbla', 'apppa', 'aaspa']) win = gtk.Window() win.connect('delete-event', gtk.main_quit) win.add(entry) win.show_all() gtk.main()
# encoding: iso-8859-1 import gtk from kiwi.ui.widgets.entry import Entry def on_entry_activate(entry): print 'You selected:', entry.get_text().encode('latin1') gtk.main_quit() entry = Entry() entry.connect('activate', on_entry_activate) entry.set_completion_strings(['Belo Horizonte', u'So Carlos', u'So Paulo', u'Bstad', u'rnskldsvik', 'sanca', 'sampa']) win = gtk.Window() win.connect('delete-event', gtk.main_quit) win.add(entry) win.show_all() gtk.main()
Extend example to include non-ASCII characters
Extend example to include non-ASCII characters
Python
lgpl-2.1
Schevo/kiwi,Schevo/kiwi,Schevo/kiwi
b25164e69d255beae1a76a9e1f7168a436a81f38
tests/test_utils.py
tests/test_utils.py
import helper from rock import utils class UtilsTestCase(helper.unittest.TestCase): def test_shell(self): utils.Shell.run = lambda self: self s = utils.Shell() self.assertTrue(isinstance(s.__enter__(), utils.Shell)) s.write('ok') s.__exit__(None, None, None) self.assertEqual(s.stdin.getvalue(), 'ok\n') def execl(*args): self.assertEqual(len(args), 4) self.assertEqual(args[0], '/bin/bash') self.assertEqual(args[1], '-l') self.assertEqual(args[2], '-c') self.assertEqual(args[3], 'ok\n') utils.os.execl = execl s.__exit__('type', 'value', 'tracebook')
import helper from rock import utils from rock.exceptions import ConfigError class UtilsTestCase(helper.unittest.TestCase): def test_shell(self): utils.Shell.run = lambda self: self s = utils.Shell() self.assertTrue(isinstance(s.__enter__(), utils.Shell)) s.write('ok') s.__exit__(None, None, None) self.assertEqual(s.stdin.getvalue(), 'ok\n') def execl(*args): self.assertEqual(len(args), 4) self.assertEqual(args[0], '/bin/bash') self.assertEqual(args[1], '-l') self.assertEqual(args[2], '-c') self.assertEqual(args[3], 'ok\n') utils.os.execl = execl s.__exit__('type', 'value', 'tracebook') def test_noshell(self): utils.ROCK_SHELL = '/tmp/hopefully-no-exists' s = utils.Shell() s.__enter__() self.assertRaises(ConfigError, s.__exit__, 'type', 'value', 'tracebook')
Test isexecutable check in utils.Shell
Test isexecutable check in utils.Shell
Python
mit
silas/rock,silas/rock,silas/rock,silas/rock,silas/rock,silas/rock,silas/rock,silas/rock
fc14e41432fece7d724aef73dd8ad7fef5e85c9a
flow/__init__.py
flow/__init__.py
from model import BaseModel from feature import Feature,JSONFeature,TextFeature,CompressedFeature,PickleFeature from extractor import Node,Graph,Aggregator,NotEnoughData from bytestream import ByteStream,ByteStreamFeature from data import \ IdProvider,UuidProvider,UserSpecifiedIdProvider,KeyBuilder\ ,StringDelimitedKeyBuilder,Database,DataWriter\ ,FileSystemDatabase,InMemoryDatabase from dependency_injection import Registry,dependency,register from nmpy import StreamingNumpyDecoder, NumpyMetaData from database_iterator import DatabaseIterator from decoder import Decoder from lmdbstore import LmdbDatabase
from model import BaseModel from feature import Feature,JSONFeature,TextFeature,CompressedFeature,PickleFeature from extractor import Node,Graph,Aggregator,NotEnoughData from bytestream import ByteStream,ByteStreamFeature from data import \ IdProvider,UuidProvider,UserSpecifiedIdProvider,KeyBuilder\ ,StringDelimitedKeyBuilder,Database,DataWriter\ ,FileSystemDatabase,InMemoryDatabase from dependency_injection import Registry,dependency,register from nmpy import StreamingNumpyDecoder, NumpyMetaData from database_iterator import DatabaseIterator from encoder import IdentityEncoder from decoder import Decoder from lmdbstore import LmdbDatabase
Add IdentityEncoder to top-level exports
Add IdentityEncoder to top-level exports
Python
mit
JohnVinyard/featureflow,JohnVinyard/featureflow
ff4477c870b9c618b7432047071792c3a8055eb7
coffeeraspi/messages.py
coffeeraspi/messages.py
class DrinkOrder(): def __init__(self, mug_size, add_ins, name=None): self.mug_size = mug_size self.add_ins = add_ins self.name = name @classmethod def deserialize(cls, data): return DrinkOrder(data['mug_size'], data['add_ins'], data.get('name', None))
class DrinkOrder(): def __init__(self, mug_size, add_ins, name=None): self.mug_size = mug_size self.add_ins = add_ins self.name = name @classmethod def deserialize(cls, data): return DrinkOrder(data['mug_size'], data['add_ins'], data.get('name', None)) def __str__(self): return 'DrinkOrder("{}")'.format(self.name if self.name else '')
Add nicer drink order logging
Add nicer drink order logging
Python
apache-2.0
umbc-hackafe/htcpcp,umbc-hackafe/htcpcp,umbc-hackafe/htcpcp,umbc-hackafe/htcpcp
056bb4adada68d96f127a7610289d874ebe0cf1b
cray_test.py
cray_test.py
# -*- coding: utf-8 -*- '''module for unit test and task for CI''' import sys import unittest from yatest import testpost, testpage, testutility, testconfig if __name__ == '__main__': all_test_suites = [] all_test_suites.append(testpost.get_test_suites()) all_test_suites.append(testpage.get_test_suites()) all_test_suites.append(testutility.get_test_suites()) all_test_suites.append(testconfig.get_test_suites()) alltests = unittest.TestSuite(all_test_suites) status = not unittest.TextTestRunner(verbosity=2).run(alltests).wasSuccessful() sys.exit(status)
# -*- coding: utf-8 -*- '''module for unit test and task for CI''' import sys import unittest from yatest import testpost, testpage, testutility, testconfig, testgenerator, testpostmanager if __name__ == '__main__': all_test_suites = [] all_test_suites.append(testpost.get_test_suites()) all_test_suites.append(testpage.get_test_suites()) all_test_suites.append(testutility.get_test_suites()) all_test_suites.append(testconfig.get_test_suites()) all_test_suites.append(testgenerator.get_test_suites()) all_test_suites.append(testpostmanager.get_test_suites()) alltests = unittest.TestSuite(all_test_suites) status = not unittest.TextTestRunner(verbosity=2).run(alltests).wasSuccessful() sys.exit(status)
Add test cases for module post_manager, refactor part of class PostManager and update TODO list.
Add test cases for module post_manager, refactor part of class PostManager and update TODO list.
Python
mit
boluny/cray,boluny/cray
ea96ed757e3709fbf8a7c12640e40ed3392d90fb
tensorflow/python/keras/preprocessing/__init__.py
tensorflow/python/keras/preprocessing/__init__.py
# Copyright 2016 The TensorFlow Authors. 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. # ============================================================================== """Keras data preprocessing utils.""" # pylint: disable=g-import-not-at-top from __future__ import absolute_import from __future__ import division from __future__ import print_function from tensorflow.python.keras.preprocessing import image from tensorflow.python.keras.preprocessing import sequence from tensorflow.python.keras.preprocessing import text del absolute_import del division del print_function
# Copyright 2016 The TensorFlow Authors. 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. # ============================================================================== """Keras data preprocessing utils.""" # pylint: disable=g-import-not-at-top from __future__ import absolute_import from __future__ import division from __future__ import print_function # TODO(mihaimaruseac): remove the import of keras_preprocessing and injecting # once we update to latest version of keras_preprocessing import keras_preprocessing from tensorflow.python.keras import backend from tensorflow.python.keras.utils import all_utils as utils # This exists for compatibility with prior version of keras_preprocessing. keras_preprocessing.set_keras_submodules(backend=backend, utils=utils) from tensorflow.python.keras.preprocessing import image from tensorflow.python.keras.preprocessing import sequence from tensorflow.python.keras.preprocessing import text del absolute_import del division del print_function
Fix build failure for mac/ubuntu, which relies on an old version for keras-preprocessing.
Fix build failure for mac/ubuntu, which relies on an old version for keras-preprocessing. PiperOrigin-RevId: 273405152
Python
apache-2.0
DavidNorman/tensorflow,gautam1858/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,freedomtan/tensorflow,davidzchen/tensorflow,aldian/tensorflow,petewarden/tensorflow,tensorflow/tensorflow-pywrap_saved_model,annarev/tensorflow,tensorflow/tensorflow,davidzchen/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,davidzchen/tensorflow,tensorflow/tensorflow,annarev/tensorflow,freedomtan/tensorflow,arborh/tensorflow,aam-at/tensorflow,annarev/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,adit-chandra/tensorflow,petewarden/tensorflow,cxxgtxy/tensorflow,karllessard/tensorflow,DavidNorman/tensorflow,adit-chandra/tensorflow,Intel-tensorflow/tensorflow,DavidNorman/tensorflow,annarev/tensorflow,yongtang/tensorflow,Intel-tensorflow/tensorflow,Intel-tensorflow/tensorflow,karllessard/tensorflow,adit-chandra/tensorflow,frreiss/tensorflow-fred,gunan/tensorflow,renyi533/tensorflow,arborh/tensorflow,gautam1858/tensorflow,arborh/tensorflow,xzturn/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,aldian/tensorflow,gunan/tensorflow,sarvex/tensorflow,annarev/tensorflow,Intel-tensorflow/tensorflow,ppwwyyxx/tensorflow,paolodedios/tensorflow,sarvex/tensorflow,tensorflow/tensorflow-pywrap_saved_model,yongtang/tensorflow,petewarden/tensorflow,gunan/tensorflow,tensorflow/tensorflow-pywrap_saved_model,xzturn/tensorflow,DavidNorman/tensorflow,DavidNorman/tensorflow,gunan/tensorflow,xzturn/tensorflow,davidzchen/tensorflow,sarvex/tensorflow,frreiss/tensorflow-fred,tensorflow/tensorflow-pywrap_tf_optimizer,aam-at/tensorflow,DavidNorman/tensorflow,aldian/tensorflow,cxxgtxy/tensorflow,renyi533/tensorflow,adit-chandra/tensorflow,jhseu/tensorflow,frreiss/tensorflow-fred,gunan/tensorflow,Intel-Corporation/tensorflow,adit-chandra/tensorflow,yongtang/tensorflow,arborh/tensorflow,gautam1858/tensorflow,aam-at/tensorflow,tensorflow/tensorflow-pywrap_saved_model,davidzchen/tensorflow,jhseu/tensorflow,gunan/tensorflow,petewarden/tensorflow,aam-at/tensorflow,DavidNorman/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,annarev/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,tensorflow/tensorflow-pywrap_tf_optimizer,aam-at/tensorflow,davidzchen/tensorflow,jhseu/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow,tensorflow/tensorflow,yongtang/tensorflow,frreiss/tensorflow-fred,freedomtan/tensorflow,annarev/tensorflow,arborh/tensorflow,davidzchen/tensorflow,paolodedios/tensorflow,sarvex/tensorflow,DavidNorman/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_saved_model,Intel-tensorflow/tensorflow,Intel-tensorflow/tensorflow,karllessard/tensorflow,adit-chandra/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow,annarev/tensorflow,jhseu/tensorflow,paolodedios/tensorflow,karllessard/tensorflow,aam-at/tensorflow,gautam1858/tensorflow,yongtang/tensorflow,xzturn/tensorflow,tensorflow/tensorflow-pywrap_saved_model,ppwwyyxx/tensorflow,cxxgtxy/tensorflow,DavidNorman/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow,jhseu/tensorflow,gunan/tensorflow,paolodedios/tensorflow,jhseu/tensorflow,adit-chandra/tensorflow,frreiss/tensorflow-fred,petewarden/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,tensorflow/tensorflow,aldian/tensorflow,jhseu/tensorflow,Intel-tensorflow/tensorflow,renyi533/tensorflow,gunan/tensorflow,annarev/tensorflow,aldian/tensorflow,tensorflow/tensorflow-pywrap_saved_model,sarvex/tensorflow,yongtang/tensorflow,ppwwyyxx/tensorflow,aam-at/tensorflow,xzturn/tensorflow,gunan/tensorflow,gautam1858/tensorflow,Intel-tensorflow/tensorflow,arborh/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,karllessard/tensorflow,renyi533/tensorflow,DavidNorman/tensorflow,Intel-tensorflow/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,xzturn/tensorflow,frreiss/tensorflow-fred,davidzchen/tensorflow,renyi533/tensorflow,jhseu/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,arborh/tensorflow,gunan/tensorflow,renyi533/tensorflow,paolodedios/tensorflow,ppwwyyxx/tensorflow,annarev/tensorflow,adit-chandra/tensorflow,tensorflow/tensorflow-pywrap_saved_model,tensorflow/tensorflow-pywrap_saved_model,freedomtan/tensorflow,cxxgtxy/tensorflow,aam-at/tensorflow,davidzchen/tensorflow,adit-chandra/tensorflow,tensorflow/tensorflow,karllessard/tensorflow,karllessard/tensorflow,petewarden/tensorflow,karllessard/tensorflow,Intel-Corporation/tensorflow,aam-at/tensorflow,tensorflow/tensorflow,jhseu/tensorflow,freedomtan/tensorflow,ppwwyyxx/tensorflow,yongtang/tensorflow,annarev/tensorflow,ppwwyyxx/tensorflow,paolodedios/tensorflow,tensorflow/tensorflow,arborh/tensorflow,adit-chandra/tensorflow,ppwwyyxx/tensorflow,sarvex/tensorflow,petewarden/tensorflow,freedomtan/tensorflow,arborh/tensorflow,arborh/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,davidzchen/tensorflow,gautam1858/tensorflow,petewarden/tensorflow,renyi533/tensorflow,DavidNorman/tensorflow,aam-at/tensorflow,sarvex/tensorflow,paolodedios/tensorflow,Intel-Corporation/tensorflow,freedomtan/tensorflow,tensorflow/tensorflow-pywrap_saved_model,xzturn/tensorflow,cxxgtxy/tensorflow,freedomtan/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,Intel-Corporation/tensorflow,aldian/tensorflow,ppwwyyxx/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,yongtang/tensorflow,petewarden/tensorflow,Intel-Corporation/tensorflow,renyi533/tensorflow,xzturn/tensorflow,frreiss/tensorflow-fred,Intel-Corporation/tensorflow,ppwwyyxx/tensorflow,xzturn/tensorflow,yongtang/tensorflow,davidzchen/tensorflow,frreiss/tensorflow-fred,frreiss/tensorflow-fred,petewarden/tensorflow,xzturn/tensorflow,xzturn/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,gautam1858/tensorflow,renyi533/tensorflow,aam-at/tensorflow,yongtang/tensorflow,paolodedios/tensorflow,karllessard/tensorflow,aldian/tensorflow,Intel-Corporation/tensorflow,renyi533/tensorflow,ppwwyyxx/tensorflow,ppwwyyxx/tensorflow,aldian/tensorflow,cxxgtxy/tensorflow,ppwwyyxx/tensorflow,karllessard/tensorflow,petewarden/tensorflow,tensorflow/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,cxxgtxy/tensorflow,cxxgtxy/tensorflow,freedomtan/tensorflow,gautam1858/tensorflow,Intel-Corporation/tensorflow,jhseu/tensorflow,adit-chandra/tensorflow,adit-chandra/tensorflow,petewarden/tensorflow,frreiss/tensorflow-fred,DavidNorman/tensorflow,aam-at/tensorflow,sarvex/tensorflow,jhseu/tensorflow,renyi533/tensorflow,gautam1858/tensorflow,tensorflow/tensorflow-pywrap_saved_model,frreiss/tensorflow-fred,gunan/tensorflow,yongtang/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,karllessard/tensorflow,renyi533/tensorflow,tensorflow/tensorflow-experimental_link_static_libraries_once,jhseu/tensorflow,arborh/tensorflow,frreiss/tensorflow-fred,arborh/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,gunan/tensorflow,paolodedios/tensorflow,paolodedios/tensorflow,xzturn/tensorflow,tensorflow/tensorflow-pywrap_tf_optimizer,Intel-tensorflow/tensorflow
58be36ca646c4bb7fd4263a592cf3a240fbca64f
post_tag.py
post_tag.py
#!/usr/bin/env python # -*- coding: utf-8 -*- from common import init, globaldata, tag_clean, tag_prefix, tag_post, tagtypes from bottle import post, request, redirect, mako_view as view @post("/post-tag") @view("post-tag") def r_post_tag(): client = init() m = request.forms.post post = client.get_post(m) tags = request.forms.tags create = request.forms.getall("create") ctype = request.forms.getall("ctype") full = set() weak = set() remove = set() failed = [] for n, t in zip(create, ctype): if t: client.add_tag(tag_clean(n), t) tags += u' ' + n for t in tags.split(): tag = client.find_tag(tag_clean(t)) if tag: p = tag_prefix(t) if p == "~": weak.add(tag) elif p == "-": remove.add(tag) else: full.add(tag) else: failed.append(t) tag_post(post, full, weak, remove) if not failed: redirect("post/" + m) data = globaldata() data.tagtypes = tagtypes() data.failed = failed data.m = m return data
#!/usr/bin/env python # -*- coding: utf-8 -*- from common import init, globaldata, tag_clean, tag_prefix, tag_post, tagtypes from bottle import post, request, redirect, mako_view as view @post("/post-tag") @view("post-tag") def r_post_tag(): client = init() m = request.forms.post post = client.get_post(m) tags = request.forms.tags create = [a.decode("utf-8") for a in request.forms.getall("create")] ctype = [a.decode("utf-8") for a in request.forms.getall("ctype")] full = set() weak = set() remove = set() failed = [] for n, t in zip(create, ctype): if t: client.add_tag(tag_clean(n), t) tags += u' ' + n for t in tags.split(): tag = client.find_tag(tag_clean(t)) if tag: p = tag_prefix(t) if p == "~": weak.add(tag) elif p == "-": remove.add(tag) else: full.add(tag) else: failed.append(t) tag_post(post, full, weak, remove) if not failed: redirect("post/" + m) data = globaldata() data.tagtypes = tagtypes() data.failed = failed data.m = m return data
Fix tag creation with non-ascii chars. (Dammit bottle!)
Fix tag creation with non-ascii chars. (Dammit bottle!)
Python
mit
drougge/wwwwellpapp,drougge/wwwwellpapp,drougge/wwwwellpapp
bb32f2327d2e3aa386fffd2fd320a7af7b03ce95
corehq/apps/domain/project_access/middleware.py
corehq/apps/domain/project_access/middleware.py
from __future__ import absolute_import from __future__ import unicode_literals from datetime import datetime, timedelta from django.utils.deprecation import MiddlewareMixin from corehq.apps.domain.project_access.models import SuperuserProjectEntryRecord, ENTRY_RECORD_FREQUENCY from corehq.util.quickcache import quickcache from corehq.apps.users.tasks import update_domain_date class ProjectAccessMiddleware(MiddlewareMixin): def process_view(self, request, view_func, view_args, view_kwargs): if getattr(request, 'couch_user', None) and request.couch_user.is_superuser \ and hasattr(request, 'domain'): return self.record_entry(request.domain, request.couch_user.username) if getattr(request, 'couch_user', None) and request.couch_user.is_web_user() \ and hasattr(request, 'domain'): self.record_web_user_entry(request.couch_user, request.domain) @quickcache(['domain', 'username'], timeout=ENTRY_RECORD_FREQUENCY.seconds) def record_entry(self, domain, username): if not SuperuserProjectEntryRecord.entry_recently_recorded(username, domain): SuperuserProjectEntryRecord.record_entry(username, domain) return None @staticmethod def record_web_user_entry(user, domain): yesterday = datetime.today() - timedelta(hours=24) if domain not in user.domains_accessed or user.domains_accessed[domain] < yesterday: update_domain_date.delay(user, domain)
from __future__ import absolute_import from __future__ import unicode_literals from datetime import datetime, timedelta from django.utils.deprecation import MiddlewareMixin from corehq.apps.domain.project_access.models import SuperuserProjectEntryRecord, ENTRY_RECORD_FREQUENCY from corehq.util.quickcache import quickcache from corehq.apps.users.tasks import update_domain_date class ProjectAccessMiddleware(MiddlewareMixin): def process_view(self, request, view_func, view_args, view_kwargs): if getattr(request, 'couch_user', None) and request.couch_user.is_superuser \ and hasattr(request, 'domain'): self.record_superuser_entry(request.domain, request.couch_user.username) if getattr(request, 'couch_user', None) and request.couch_user.is_web_user() \ and hasattr(request, 'domain'): self.record_web_user_entry(request.couch_user, request.domain) @quickcache(['domain', 'username'], timeout=ENTRY_RECORD_FREQUENCY.seconds) def record_superuser_entry(self, domain, username): if not SuperuserProjectEntryRecord.entry_recently_recorded(username, domain): SuperuserProjectEntryRecord.record_entry(username, domain) return None @staticmethod def record_web_user_entry(user, domain): yesterday = datetime.today() - timedelta(hours=24) if domain not in user.domains_accessed or user.domains_accessed[domain] < yesterday: update_domain_date.delay(user, domain)
Include superusers in web user domaing access record
Include superusers in web user domaing access record
Python
bsd-3-clause
dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq
dd336c7555390d2713ef896f49ba27dbadc80a14
tests/server/extensions/test_execute_command.py
tests/server/extensions/test_execute_command.py
"""Tests for execute commands function""" import os import subprocess import pytest from scout.server.extensions.loqus_extension import execute_command TRAVIS = os.getenv("TRAVIS") GITHUB = os.getenv("GITHUB") def test_run_execute_command(): """Test run echo with execute command""" # GIVEN a command to run in the shell output = "hello world" cmd = ["echo", output] # WHEN running it with execute command res = execute_command(cmd) # THEN assert the output is correct assert res.strip() == output @pytest.mark.skipif(TRAVIS, reason="Unknown problems on travis") @pytest.mark.skipif(GITHUB, reason="Unknown problems on github actions") def test_run_failing_command(): """Test run a failing command with execute command""" # GIVEN a command that will fail when run in the shell cmd = ["cd", "nonexistingdirectory"] exception = subprocess.CalledProcessError # WHEN running it with execute command with pytest.raises(exception): # THEN assert that an exception is raised execute_command(cmd) @pytest.mark.skipif(TRAVIS, reason="Unknown problems on travis") @pytest.mark.skipif(GITHUB, reason="Unknown problems on github actions") def test_run_command_no_output(): """Test run a command without output""" # GIVEN a command that returns no output cmd = ["cd", "./"] # WHEN running it with execute command res = execute_command(cmd) # THEN assert that the empty string is returned assert res == ""
"""Tests for execute commands function""" import os import subprocess import pytest from scout.server.extensions.loqus_extension import execute_command TRAVIS = os.getenv("TRAVIS") GITHUB = os.getenv("CI") def test_run_execute_command(): """Test run echo with execute command""" # GIVEN a command to run in the shell output = "hello world" cmd = ["echo", output] # WHEN running it with execute command res = execute_command(cmd) # THEN assert the output is correct assert res.strip() == output @pytest.mark.skipif(TRAVIS, reason="Unknown problems on travis") @pytest.mark.skipif(GITHUB, reason="Unknown problems on github actions") def test_run_failing_command(): """Test run a failing command with execute command""" # GIVEN a command that will fail when run in the shell cmd = ["cd", "nonexistingdirectory"] exception = subprocess.CalledProcessError # WHEN running it with execute command with pytest.raises(exception): # THEN assert that an exception is raised execute_command(cmd) @pytest.mark.skipif(TRAVIS, reason="Unknown problems on travis") @pytest.mark.skipif(GITHUB, reason="Unknown problems on github actions") def test_run_command_no_output(): """Test run a command without output""" # GIVEN a command that returns no output cmd = ["cd", "./"] # WHEN running it with execute command res = execute_command(cmd) # THEN assert that the empty string is returned assert res == ""
Use correct env to check if on github
Use correct env to check if on github
Python
bsd-3-clause
Clinical-Genomics/scout,Clinical-Genomics/scout,Clinical-Genomics/scout
6d8e535a56ee2f05f051d101ee5f3903176f19fe
rnacentral/rnacentral/local_settings_default.py
rnacentral/rnacentral/local_settings_default.py
""" Copyright [2009-2014] EMBL-European Bioinformatics Institute 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. """ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.', 'NAME': '', 'USER': '', 'PASSWORD': '', 'OPTIONS' : { 'init_command' : 'SET storage_engine=MyISAM', }, } } TEMPLATE_DIRS = ( '', ) STATIC_ROOT = '' EMAIL_HOST = '' EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' EMAIL_PORT = EMAIL_USE_TLS = True EMAIL_RNACENTRAL_HELPDESK = '' SECRET_KEY = '' ADMINS = ( ('', ''), ) COMPRESS_ENABLED = DEBUG = ALLOWED_HOSTS = [] # django-debug-toolbar INTERNAL_IPS = ('127.0.0.1',)
""" Copyright [2009-2014] EMBL-European Bioinformatics Institute 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. """ DATABASES = { 'default': { 'ENGINE': 'django.db.backends.oracle', 'NAME': '(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=)(PORT=))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=)))', 'USER': '', 'PASSWORD': '', 'OPTIONS': { 'threaded': True, }, } } TEMPLATE_DIRS = ( '', ) STATIC_ROOT = '' EMAIL_HOST = '' EMAIL_HOST_USER = '' EMAIL_HOST_PASSWORD = '' EMAIL_PORT = EMAIL_USE_TLS = True EMAIL_RNACENTRAL_HELPDESK = '' SECRET_KEY = '' ADMINS = ( ('', ''), ) COMPRESS_ENABLED = False DEBUG = False ALLOWED_HOSTS = [] # django-debug-toolbar INTERNAL_IPS = ('127.0.0.1',) # django-maintenance MAINTENANCE_MODE = False
Update the default settings file to include the database threaded option
Update the default settings file to include the database threaded option
Python
apache-2.0
RNAcentral/rnacentral-webcode,RNAcentral/rnacentral-webcode,RNAcentral/rnacentral-webcode,RNAcentral/rnacentral-webcode
3d3809931b5683b69e57507320b6d78df102f8d1
warehouse/database/mixins.py
warehouse/database/mixins.py
from sqlalchemy.dialects import postgresql as pg from sqlalchemy.sql import func from sqlalchemy.sql.expression import text from warehouse import db from warehouse.database.schema import TableDDL class UUIDPrimaryKeyMixin(object): id = db.Column(pg.UUID(as_uuid=True), primary_key=True, server_default=text("uuid_generate_v4()")) class TimeStampedMixin(object): __table_args__ = ( TableDDL(""" CREATE OR REPLACE FUNCTION update_modified_column() RETURNS TRIGGER AS $$ BEGIN NEW.modified = now(); RETURN NEW; END; $$ LANGUAGE 'plpgsql'; CREATE TRIGGER update_%(table)s_modtime BEFORE UPDATE ON %(table)s FOR EACH ROW EXECUTE PROCEDURE update_modified_column(); """), ) created = db.Column(db.DateTime, server_default=func.now(), nullable=False) modified = db.Column(db.DateTime, server_default=func.now(), nullable=False)
from sqlalchemy.dialects import postgresql as pg from sqlalchemy.schema import FetchedValue from sqlalchemy.sql import func from sqlalchemy.sql.expression import text from warehouse import db from warehouse.database.schema import TableDDL class UUIDPrimaryKeyMixin(object): id = db.Column(pg.UUID(as_uuid=True), primary_key=True, server_default=text("uuid_generate_v4()")) class TimeStampedMixin(object): __table_args__ = ( TableDDL(""" CREATE OR REPLACE FUNCTION update_modified_column() RETURNS TRIGGER AS $$ BEGIN NEW.modified = now(); RETURN NEW; END; $$ LANGUAGE 'plpgsql'; CREATE TRIGGER update_%(table)s_modtime BEFORE UPDATE ON %(table)s FOR EACH ROW EXECUTE PROCEDURE update_modified_column(); """), ) created = db.Column(db.DateTime, nullable=False, server_default=func.now()) modified = db.Column(db.DateTime, nullable=False, server_default=func.now(), server_onupdate=FetchedValue())
Mark TimeStampedMixin.modified as an onupdate FetchedValue
Mark TimeStampedMixin.modified as an onupdate FetchedValue
Python
bsd-2-clause
davidfischer/warehouse
d9f20935f6a0d5bf4e2c1dd1a3c5b41167f8518b
email_log/migrations/0001_initial.py
email_log/migrations/0001_initial.py
# encoding: utf8 from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='Email', fields=[ (u'id', models.AutoField(verbose_name=u'ID', serialize=False, auto_created=True, primary_key=True)), ('from_email', models.TextField(verbose_name=u'from e-mail')), ('recipients', models.TextField(verbose_name=u'recipients')), ('subject', models.TextField(verbose_name=u'subject')), ('body', models.TextField(verbose_name=u'body')), ('ok', models.BooleanField(default=False, db_index=True, verbose_name=u'ok')), ('date_sent', models.DateTimeField(auto_now_add=True, verbose_name=u'date sent', db_index=True)), ], options={ u'ordering': (u'-date_sent',), u'verbose_name': u'e-mail', u'verbose_name_plural': u'e-mails', }, bases=(models.Model,), ), ]
# encoding: utf8 from django.db import models, migrations class Migration(migrations.Migration): dependencies = [ ] operations = [ migrations.CreateModel( name='Email', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('from_email', models.TextField(verbose_name='from e-mail')), ('recipients', models.TextField(verbose_name='recipients')), ('subject', models.TextField(verbose_name='subject')), ('body', models.TextField(verbose_name='body')), ('ok', models.BooleanField(default=False, db_index=True, verbose_name='ok')), ('date_sent', models.DateTimeField(auto_now_add=True, verbose_name='date sent', db_index=True)), ], options={ 'ordering': ('-date_sent',), 'verbose_name': 'e-mail', 'verbose_name_plural': 'e-mails', }, bases=(models.Model,), ), ]
Fix migration file for Python 3.2 (and PEP8)
Fix migration file for Python 3.2 (and PEP8)
Python
mit
treyhunner/django-email-log,treyhunner/django-email-log
733404ba2eb7218bb4d253cd74fe88107ff75afc
test/test_live_openid_login.py
test/test_live_openid_login.py
import time import pytest from chatexchange.browser import SEChatBrowser, LoginError import live_testing if live_testing.enabled: def test_openid_login(): """ Tests login to the Stack Exchange OpenID provider. """ browser = SEChatBrowser() # avoid hitting the SE servers too frequently time.sleep(2) # This will raise an error if login fails. browser.loginSEOpenID( live_testing.username, live_testing.password) def test_openid_login_recognizes_failure(): """ Tests that failed SE OpenID logins raise errors. """ browser = SEChatBrowser() # avoid hitting the SE servers too frequently time.sleep(2) with pytest.raises(LoginError): invalid_password = 'no' + 't' * len(live_testing.password) browser.loginSEOpenID( live_testing.username, invalid_password)
import time import pytest from chatexchange.browser import SEChatBrowser, LoginError import live_testing if live_testing.enabled: def test_openid_login_recognizes_failure(): """ Tests that failed SE OpenID logins raise errors. """ browser = SEChatBrowser() # avoid hitting the SE servers too frequently time.sleep(2) with pytest.raises(LoginError): invalid_password = 'no' + 't' * len(live_testing.password) browser.loginSEOpenID( live_testing.username, invalid_password)
Remove successful OpenID login live test. It's redundant with our message-related live tests.
Remove successful OpenID login live test. It's redundant with our message-related live tests.
Python
apache-2.0
ByteCommander/ChatExchange6,hichris1234/ChatExchange,Charcoal-SE/ChatExchange,hichris1234/ChatExchange,ByteCommander/ChatExchange6,Charcoal-SE/ChatExchange
210e99b9b19484991f4d7d4106ed9c0ae802b2f7
windmill/server/__init__.py
windmill/server/__init__.py
# Copyright (c) 2006-2007 Open Source Applications Foundation # Copyright (c) 2008-2009 Mikeal Rogers <[email protected]> # # 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 wsgi, convergence forwarding_conditions = [ lambda e : 'google.com/safebrowsing/downloads' not in e['reconstructed_url'], lambda e : 'mozilla.org/en-US/firefox/livebookmarks.html' not in e['reconstructed_url'], ] def add_forward_condition(condition): forwarding_conditions.append(condition) def remove_forward_condition(condition): while condition in forwarding_conditions: forwarding_conditions.remove(condition)
# Copyright (c) 2006-2007 Open Source Applications Foundation # Copyright (c) 2008-2009 Mikeal Rogers <[email protected]> # # 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 wsgi, convergence forwarding_conditions = [ lambda e : 'google.com/safebrowsing/downloads' not in e['reconstructed_url'], lambda e : 'mozilla.org/en-US/firefox/livebookmarks.html' not in e['reconstructed_url'], lambda e : e.get('CONTENT_TYPE') != 'application/x-shockwave-flash', ] def add_forward_condition(condition): forwarding_conditions.append(condition) def remove_forward_condition(condition): while condition in forwarding_conditions: forwarding_conditions.remove(condition)
Stop forwarding flash by default, it breaks more than it doesn't.
Stop forwarding flash by default, it breaks more than it doesn't. git-svn-id: 87d19257dd11500985d055ec4730e446075a5f07@1279 78c7df6f-8922-0410-bcd3-9426b1ad491b
Python
apache-2.0
windmill/windmill,windmill/windmill,windmill/windmill,windmill/windmill,windmill/windmill,windmill/windmill
9c428fbfb69c93ef3da935d0d2ab098fbeb1c317
dsh.py
dsh.py
# ----- Info ------------------------------------------------------------------ __author__ = 'Michael Montero <[email protected]>' # ----- Imports --------------------------------------------------------------- from tinyAPI.base.data_store.provider import DataStoreProvider import tinyAPI __all__ = [ 'dsh' ] # ----- Private Classes ------------------------------------------------------- class NoOpDSH(object): ''' The use of this object in __DSH is ambiguous. It's unclear why a call to a commit or rollback command would be executed without a connection ever being established. ''' def close(self): pass def commit(self, ignore_exceptions=True): pass def rollback(self, ignore_exceptions=True): pass # ----- Instructions ---------------------------------------------------------- class __DSH(object): def __init__(self): self.__provider = None def __call__(self): return self.__provider if self.__provider is not None else NoOpDSH() def select_db(self, connection, db, persistent=True): self.__provider = \ DataStoreProvider() \ .get_data_store_handle( connection, db, tinyAPI.env_cli() is not True and persistent ) return self dsh = __DSH()
# ----- Info ------------------------------------------------------------------ __author__ = 'Michael Montero <[email protected]>' # ----- Imports --------------------------------------------------------------- from tinyAPI.base.data_store.provider import DataStoreProvider import tinyAPI __all__ = [ 'dsh' ] # ----- Private Classes ------------------------------------------------------- class UnitTestNullDSH(object): ''' Supports unit test cases that do not perform transactional data store operations but attempt to close or rollback transactions. ''' def close(self): pass def rollback(self, ignore_exceptions=True): pass # ----- Instructions ---------------------------------------------------------- class __DSH(object): def __init__(self): self.__provider = None self.__unit_test_null_dsh = UnitTestNullDSH() def __call__(self): if self.__provider is None: if tinyAPI.env_unit_test() is True: return self.__unit_test_null_dsh else: raise RuntimeError('data store handle has not been selected') return self.__provider def select_db(self, connection, db, persistent=True): self.__provider = \ DataStoreProvider() \ .get_data_store_handle( connection, db, tinyAPI.env_cli() is not True and persistent ) return self dsh = __DSH()
Revert "Testing NoOpDSH() when database commands are executed without a connection being opened."
Revert "Testing NoOpDSH() when database commands are executed without a connection being opened." This reverts commit 57dd36da6f558e9bd5c9b7c97e955600c2fa0b8e.
Python
mit
mcmontero/tinyAPI,mcmontero/tinyAPI
eced06f6f523fa6fd475987ae688b7ca2b6c3415
checks/system/__init__.py
checks/system/__init__.py
""" Return information about the given platform. """ import sys class Platform(object): @staticmethod def is_darwin(name=None): name = name or sys.platform return 'darwin' in name @staticmethod def is_freebsd(name=None): name = name or sys.platform return name.startswith("freebsd") @staticmethod def is_linux(name=None): name = name or sys.platform return 'linux' in name @staticmethod def is_bsd(name=None): """ Return true if this is a BSD like operating system. """ name = name or sys.platform return Platform.is_darwin(name) or Platform.is_freebsd(name) @staticmethod def is_solaris(name=None): name = name or sys.platform return name == "sunos5" @staticmethod def is_unix(name=None): """ Return true if the platform is a unix, False otherwise. """ name = name or sys.platform return (Platform.is_darwin() or Platform.is_linux() or Platform.is_freebsd() )
""" Return information about the given platform. """ import sys class Platform(object): @staticmethod def is_darwin(name=None): name = name or sys.platform return 'darwin' in name @staticmethod def is_freebsd(name=None): name = name or sys.platform return name.startswith("freebsd") @staticmethod def is_linux(name=None): name = name or sys.platform return 'linux' in name @staticmethod def is_bsd(name=None): """ Return true if this is a BSD like operating system. """ name = name or sys.platform return Platform.is_darwin(name) or Platform.is_freebsd(name) @staticmethod def is_solaris(name=None): name = name or sys.platform return name == "sunos5" @staticmethod def is_unix(name=None): """ Return true if the platform is a unix, False otherwise. """ name = name or sys.platform return (Platform.is_darwin() or Platform.is_linux() or Platform.is_freebsd() ) @staticmethod def is_win32(name=None): name = name or sys.platform return name == "win32"
Add win32 to platform information
Add win32 to platform information
Python
bsd-3-clause
jraede/dd-agent,tebriel/dd-agent,JohnLZeller/dd-agent,a20012251/dd-agent,remh/dd-agent,tebriel/dd-agent,AntoCard/powerdns-recursor_check,tebriel/dd-agent,AniruddhaSAtre/dd-agent,urosgruber/dd-agent,polynomial/dd-agent,JohnLZeller/dd-agent,Mashape/dd-agent,JohnLZeller/dd-agent,eeroniemi/dd-agent,c960657/dd-agent,mderomph-coolblue/dd-agent,ess/dd-agent,jraede/dd-agent,Shopify/dd-agent,truthbk/dd-agent,eeroniemi/dd-agent,relateiq/dd-agent,AntoCard/powerdns-recursor_check,oneandoneis2/dd-agent,darron/dd-agent,AniruddhaSAtre/dd-agent,packetloop/dd-agent,joelvanvelden/dd-agent,zendesk/dd-agent,tebriel/dd-agent,pfmooney/dd-agent,lookout/dd-agent,polynomial/dd-agent,yuecong/dd-agent,AniruddhaSAtre/dd-agent,yuecong/dd-agent,jyogi/purvar-agent,GabrielNicolasAvellaneda/dd-agent,GabrielNicolasAvellaneda/dd-agent,jraede/dd-agent,oneandoneis2/dd-agent,urosgruber/dd-agent,packetloop/dd-agent,citrusleaf/dd-agent,manolama/dd-agent,indeedops/dd-agent,zendesk/dd-agent,PagerDuty/dd-agent,gphat/dd-agent,takus/dd-agent,truthbk/dd-agent,guruxu/dd-agent,yuecong/dd-agent,Mashape/dd-agent,cberry777/dd-agent,jshum/dd-agent,jshum/dd-agent,cberry777/dd-agent,PagerDuty/dd-agent,c960657/dd-agent,gphat/dd-agent,ess/dd-agent,GabrielNicolasAvellaneda/dd-agent,benmccann/dd-agent,manolama/dd-agent,benmccann/dd-agent,jvassev/dd-agent,pfmooney/dd-agent,huhongbo/dd-agent,polynomial/dd-agent,jvassev/dd-agent,jraede/dd-agent,jamesandariese/dd-agent,benmccann/dd-agent,brettlangdon/dd-agent,takus/dd-agent,pfmooney/dd-agent,lookout/dd-agent,amalakar/dd-agent,cberry777/dd-agent,joelvanvelden/dd-agent,huhongbo/dd-agent,remh/dd-agent,jyogi/purvar-agent,Mashape/dd-agent,eeroniemi/dd-agent,indeedops/dd-agent,pmav99/praktoras,darron/dd-agent,yuecong/dd-agent,brettlangdon/dd-agent,urosgruber/dd-agent,relateiq/dd-agent,jamesandariese/dd-agent,AntoCard/powerdns-recursor_check,amalakar/dd-agent,ess/dd-agent,pmav99/praktoras,amalakar/dd-agent,citrusleaf/dd-agent,amalakar/dd-agent,c960657/dd-agent,jshum/dd-agent,huhongbo/dd-agent,polynomial/dd-agent,oneandoneis2/dd-agent,Shopify/dd-agent,Wattpad/dd-agent,brettlangdon/dd-agent,JohnLZeller/dd-agent,jshum/dd-agent,citrusleaf/dd-agent,joelvanvelden/dd-agent,tebriel/dd-agent,guruxu/dd-agent,lookout/dd-agent,packetloop/dd-agent,a20012251/dd-agent,manolama/dd-agent,PagerDuty/dd-agent,Wattpad/dd-agent,AntoCard/powerdns-recursor_check,jraede/dd-agent,mderomph-coolblue/dd-agent,takus/dd-agent,indeedops/dd-agent,Wattpad/dd-agent,Wattpad/dd-agent,joelvanvelden/dd-agent,amalakar/dd-agent,yuecong/dd-agent,jamesandariese/dd-agent,packetloop/dd-agent,benmccann/dd-agent,oneandoneis2/dd-agent,Shopify/dd-agent,mderomph-coolblue/dd-agent,jvassev/dd-agent,mderomph-coolblue/dd-agent,darron/dd-agent,AniruddhaSAtre/dd-agent,mderomph-coolblue/dd-agent,a20012251/dd-agent,gphat/dd-agent,c960657/dd-agent,remh/dd-agent,Mashape/dd-agent,remh/dd-agent,relateiq/dd-agent,benmccann/dd-agent,darron/dd-agent,GabrielNicolasAvellaneda/dd-agent,pmav99/praktoras,relateiq/dd-agent,indeedops/dd-agent,jyogi/purvar-agent,brettlangdon/dd-agent,joelvanvelden/dd-agent,zendesk/dd-agent,pfmooney/dd-agent,Shopify/dd-agent,guruxu/dd-agent,lookout/dd-agent,jyogi/purvar-agent,eeroniemi/dd-agent,pmav99/praktoras,manolama/dd-agent,jamesandariese/dd-agent,urosgruber/dd-agent,Mashape/dd-agent,huhongbo/dd-agent,Wattpad/dd-agent,truthbk/dd-agent,AntoCard/powerdns-recursor_check,relateiq/dd-agent,guruxu/dd-agent,JohnLZeller/dd-agent,a20012251/dd-agent,takus/dd-agent,truthbk/dd-agent,cberry777/dd-agent,remh/dd-agent,eeroniemi/dd-agent,urosgruber/dd-agent,brettlangdon/dd-agent,oneandoneis2/dd-agent,gphat/dd-agent,citrusleaf/dd-agent,pmav99/praktoras,zendesk/dd-agent,Shopify/dd-agent,GabrielNicolasAvellaneda/dd-agent,polynomial/dd-agent,jvassev/dd-agent,jamesandariese/dd-agent,PagerDuty/dd-agent,ess/dd-agent,truthbk/dd-agent,cberry777/dd-agent,PagerDuty/dd-agent,AniruddhaSAtre/dd-agent,a20012251/dd-agent,guruxu/dd-agent,jvassev/dd-agent,indeedops/dd-agent,c960657/dd-agent,packetloop/dd-agent,jshum/dd-agent,zendesk/dd-agent,takus/dd-agent,lookout/dd-agent,jyogi/purvar-agent,ess/dd-agent,manolama/dd-agent,gphat/dd-agent,citrusleaf/dd-agent,pfmooney/dd-agent,huhongbo/dd-agent,darron/dd-agent
1c5f36b0f133ff668f17a1f023c2d52dc2bfbf49
generate_files_json.py
generate_files_json.py
#!/usr/bin/python3 import os import json import glob data = {} data['comparisonfiles'] = {} for subset in next(os.walk("comparisonfiles/"))[1]: data['comparisonfiles'][subset] = {} data['comparisonfiles'][subset]["format"] = [] format_list = [ format for format in next(os.walk("comparisonfiles/" + subset + "/large"))[1] ] for format in format_list: extension = [ os.path.splitext(os.path.basename(fn))[1][1:] for fn in glob.glob( "comparisonfiles/" + subset + "/large/" + format + "/*") if os.path.splitext(os.path.basename(fn))[1] != "png" ][0] data['comparisonfiles'][subset]["format"].append({ "extension": extension, "name": format }) data['comparisonfiles'][subset]["format"].append({ "extension": "png", "name": "Original" }) filenames_list = [ os.path.splitext(os.path.basename(files))[0] for files in next( os.walk("comparisonfiles/" + subset + "/Original/"))[2] ] data['comparisonfiles'][subset]["files"] = [] for filename in filenames_list: data['comparisonfiles'][subset]["files"].append({ "title": "", "filename": filename }) with open('comparisonfiles.json', 'w') as outfile: json.dump(data, outfile, indent=4)
#!/usr/bin/python3 import os import json import glob data = {} data['comparisonfiles'] = {} for subset in next(os.walk("comparisonfiles/"))[1]: data['comparisonfiles'][subset] = {} data['comparisonfiles'][subset]["format"] = [] format_list = [ format for format in next(os.walk("comparisonfiles/" + subset + "/large"))[1] ] for format in format_list: extension = [ os.path.splitext(os.path.basename(fn))[1][1:] for fn in glob.glob( "comparisonfiles/" + subset + "/large/" + format + "/*") if os.path.splitext(os.path.basename(fn))[1] != ".png" ][0] data['comparisonfiles'][subset]["format"].append({ "extension": extension, "name": format }) data['comparisonfiles'][subset]["format"].append({ "extension": "png", "name": "Original" }) filenames_list = [ os.path.splitext(os.path.basename(files))[0] for files in next( os.walk("comparisonfiles/" + subset + "/Original/"))[2] ] data['comparisonfiles'][subset]["files"] = [] for filename in filenames_list: data['comparisonfiles'][subset]["files"].append({ "title": "", "filename": filename }) with open('comparisonfiles.json', 'w') as outfile: json.dump(data, outfile, indent=4)
Fix extension detection in JSON generation
Fix extension detection in JSON generation
Python
bsd-3-clause
WyohKnott/image-comparison-sources
ba6ef2ac850c91ac8a72401b7bd7b130bc2cc1d6
docs/conf.py
docs/conf.py
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import setuptools_scm extensions = [ 'sphinx.ext.autodoc', ] # General information about the project. project = 'jaraco.logging' copyright = '2015 Jason R. Coombs' # The short X.Y version. version = setuptools_scm.get_version(root='..') # The full version, including alpha/beta/rc tags. release = version master_doc = 'index'
#!/usr/bin/env python3 # -*- coding: utf-8 -*- import setuptools_scm extensions = [ 'sphinx.ext.autodoc', ] # General information about the project. project = 'jaraco.logging' copyright = '2015 Jason R. Coombs' # The short X.Y version. version = setuptools_scm.get_version(root='..', relative_to=__file__) # The full version, including alpha/beta/rc tags. release = version master_doc = 'index'
Fix version detection for tests
Fix version detection for tests
Python
mit
jaraco/jaraco.logging
b974bbcc7e243fca7c3dc63fbbaf530fe9b69e50
runtests.py
runtests.py
import sys try: from django.conf import settings from django.test.utils import get_runner settings.configure( DEBUG=True, USE_TZ=True, DATABASES={ "default": { "ENGINE": "django.db.backends.sqlite3", "NAME": ":memory:", } }, INSTALLED_APPS=[ "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.staticfiles", "django.contrib.sites", "chartit", "chartit_tests", ], SITE_ID=1, MIDDLEWARE_CLASSES=(), STATIC_URL='/static/' ) try: import django setup = django.setup except AttributeError: pass else: setup() except ImportError: import traceback traceback.print_exc() raise ImportError("To fix this error, run: pip install -r requirements.txt") def run_tests(*test_args): if not test_args: test_args = ["chartit_tests"] # Run tests TestRunner = get_runner(settings) test_runner = TestRunner() failures = test_runner.run_tests(test_args) if failures: sys.exit(bool(failures)) if __name__ == "__main__": run_tests(*sys.argv[1:])
import os import sys try: sys.path.append('demoproject') os.environ.setdefault("DJANGO_SETTINGS_MODULE", "demoproject.settings") from django.conf import settings from django.core.management import call_command settings.DATABASES['default']['NAME'] = ':memory:' settings.INSTALLED_APPS.append('chartit_tests') try: import django setup = django.setup except AttributeError: pass else: setup() except ImportError: import traceback traceback.print_exc() raise ImportError("To fix this error, run: pip install -r requirements.txt") def run_tests(*test_args): if not test_args: test_args = ["chartit_tests"] # ./manage.py test takes care of database creation and # application of migrations if any result = call_command('test', *test_args, verbosity=2, failfast=True) sys.exit(result) if __name__ == "__main__": run_tests(*sys.argv[1:])
Load DB migrations before testing and use verbose=2 and failfast
Load DB migrations before testing and use verbose=2 and failfast Note that we use `manage.py test` instead of `manage.py migrate` and manually running the tests. This lets Django take care of applying migrations before running tests. This works around https://code.djangoproject.com/ticket/22487 which causes a test failure on Django 1.8.14. In 1.8.14 somehow we end up without any actual data in the test DB and one of the tests fails if we use `manage.py migrate` and run the tests manually via TestRunner.
Python
bsd-2-clause
pgollakota/django-chartit,pgollakota/django-chartit,pgollakota/django-chartit
471bb3847b78f36f79af6cbae288a8876357cb3c
runtests.py
runtests.py
#!/usr/bin/env python import sys from django.conf import settings from django.core.management import execute_from_command_line if not settings.configured: params = dict( LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'class': 'logging.StreamHandler', }, }, 'loggers': { 'wagtailgeowidget': { 'handlers': ['console'], 'level': 'ERROR', 'propagate': True, }, }, }, DATABASES={ "default": { "ENGINE": "django.db.backends.sqlite3", } }, INSTALLED_APPS=[ 'django.contrib.contenttypes', 'django.contrib.auth', 'django.contrib.sites', 'wagtail.core', 'wagtail.sites', 'wagtail.users', 'wagtail.images', 'taggit', 'wagtailgeowidget', "tests", ], MIDDLEWARE_CLASSES=[], ROOT_URLCONF='tests.urls', ) settings.configure(**params) def runtests(): argv = sys.argv[:1] + ["test"] + sys.argv[1:] execute_from_command_line(argv) if __name__ == "__main__": runtests()
#!/usr/bin/env python import sys from django.conf import settings from django.core.management import execute_from_command_line if not settings.configured: params = dict( LOGGING = { 'version': 1, 'disable_existing_loggers': False, 'handlers': { 'console': { 'class': 'logging.StreamHandler', }, }, 'loggers': { 'wagtailgeowidget': { 'handlers': ['console'], 'level': 'ERROR', 'propagate': True, }, }, }, DATABASES={ "default": { "ENGINE": "django.db.backends.sqlite3", } }, INSTALLED_APPS=[ 'django.contrib.contenttypes', 'django.contrib.auth', 'django.contrib.sites', 'wagtail.core', "wagtail.admin", 'wagtail.sites', 'wagtail.users', 'wagtail.images', 'taggit', 'wagtailgeowidget', "tests", ], MIDDLEWARE_CLASSES=[], ROOT_URLCONF='tests.urls', SECRET_KEY="secret key", ) settings.configure(**params) def runtests(): argv = sys.argv[:1] + ["test"] + sys.argv[1:] execute_from_command_line(argv) if __name__ == "__main__": runtests()
Add missing config that caused test to fail
Add missing config that caused test to fail
Python
mit
Frojd/wagtail-geo-widget,Frojd/wagtail-geo-widget,Frojd/wagtail-geo-widget,Frojd/wagtail-geo-widget
25224af8c002c05397e5c3163f0b77cb82ce325e
data_collection/management/commands/assignfirms.py
data_collection/management/commands/assignfirms.py
from django.core.management.base import BaseCommand, CommandError from data_collection.models import User, Firm, Assignment import itertools class Command(BaseCommand): help = "Assign firms to users" def add_arguments(self, parser): parser.add_argument('users', nargs='+', type=str) def handle(self, *args, **options): users = [User.objects.get(username=username) for username in options['users']] for user, firm in itertools.izip(itertools.cycle(users), Firm.objects.all().order_by('?')): Assignment.objects.get_or_create(user=user, firm=firm) print 'Assigned %s to %s' % (firm.domain, user.username)
from django.core.management.base import BaseCommand, CommandError from data_collection.models import User, Firm, Assignment import itertools, random class Command(BaseCommand): help = "Assign firms to users" def add_arguments(self, parser): parser.add_argument('users', nargs='+', type=str) parser.add_argument('-d', '--drop', dest="drop", default=False, action="store_true", help="Drop current assignments") parser.add_argument('-p', '--percentage', dest="percentage", action="store", type=int, nargs="+") def handle(self, *args, **options): if options['drop']: Assignment.objects.all().delete() if options['percentage']: if len(options['percentage']) != len(options['users']): raise CommandError('If you specify percentages, you must specify the same number as you specify users') percentage = options['percentage'] else: percentage = [1] * len(options['users']) # make a list that has the requested usernames distributed as requested users = sorted( itertools.chain.from_iterable( [[User.objects.get(username=username)] * count for username, count in zip(options['users'], percentage)] ), key = lambda x: random.random() ) for user, firm in itertools.izip(itertools.cycle(users), Firm.objects.all().order_by('?')): Assignment.objects.get_or_create(user=user, firm=firm) print 'Assigned %s to %s' % (firm.domain, user.username)
Add ability to proportionally assign to different users
Add ability to proportionally assign to different users
Python
bsd-3-clause
sunlightlabs/hanuman,sunlightlabs/hanuman,sunlightlabs/hanuman
54b3b69d152611d55ce7db66c2c34dc2b1140cc7
wellknown/models.py
wellknown/models.py
from django.db import models from django.db.models.signals import post_save import mimetypes import wellknown # # create default host-meta handler # from wellknown.resources import HostMeta wellknown.register('host-meta', handler=HostMeta(), content_type='application/xrd+xml') # # resource model # class Resource(models.Model): path = models.CharField(max_length=128) content = models.TextField(blank=True) content_type = models.CharField(max_length=128, blank=True) class Meta: ordering = ('path',) def __unicode__(self): return self.path def save(self, **kwargs): self.path = self.path.strip('/') if not self.content_type: self.content_type = mimetypes.guess_type(self.path)[0] or 'text/plain' super(Resource, self).save(**kwargs) # # update resources when models are saved # def save_handler(sender, **kwargs): reg = kwargs['instance'] wellknown.register( reg.path, content=reg.content, content_type=reg.content_type, update=True ) post_save.connect(save_handler, sender=Resource) # # cache resources # for res in Resource.objects.all(): wellknown.register(res.path, content=res.content, content_type=res.content_type)
from django.db import models from django.db.models.signals import post_save import mimetypes import wellknown # # create default host-meta handler # from wellknown.resources import HostMeta wellknown.register('host-meta', handler=HostMeta(), content_type='application/xrd+xml') # # resource model # class Resource(models.Model): path = models.CharField(max_length=128) content = models.TextField(blank=True) content_type = models.CharField(max_length=128, blank=True) class Meta: ordering = ('path',) def __unicode__(self): return self.path def save(self, **kwargs): self.path = self.path.strip('/') if not self.content_type: self.content_type = mimetypes.guess_type(self.path)[0] or 'text/plain' super(Resource, self).save(**kwargs) # # update resources when models are saved # def save_handler(sender, **kwargs): reg = kwargs['instance'] wellknown.register( reg.path, content=reg.content, content_type=reg.content_type, update=True ) post_save.connect(save_handler, sender=Resource)
Remove code that was causing a problem running syncdb. Code seems to be redundant anyway.
Remove code that was causing a problem running syncdb. Code seems to be redundant anyway.
Python
bsd-3-clause
jcarbaugh/django-wellknown
4e7917ab5a2e112af8c69b89805af6b097eed97e
examples/custom_table_caching/grammar.py
examples/custom_table_caching/grammar.py
from parglare import Grammar grammar = Grammar.from_string(""" start: ab EOF; ab: "a" ab "b" | EMPTY; """) start_symbol = 'start'
from parglare import Grammar grammar = Grammar.from_string(""" start: ab; ab: "a" ab "b" | EMPTY; """) start_symbol = 'start'
Remove `EOF` -- update examples
Remove `EOF` -- update examples refs #64
Python
mit
igordejanovic/parglare,igordejanovic/parglare
75289980c658e081fec2d7e34651837c4629d4b7
settings.py
settings.py
# -*- coding: utf-8 -*- """ * Project: udacity-fsnd-p4-conference-app * Author name: Iraquitan Cordeiro Filho * Author login: iraquitan * File: settings * Date: 3/23/16 * Time: 12:16 AM """ # Replace the following lines with client IDs obtained from the APIs # Console or Cloud Console. WEB_CLIENT_ID = 'your-app-id'
# -*- coding: utf-8 -*- """ * Project: udacity-fsnd-p4-conference-app * Author name: Iraquitan Cordeiro Filho * Author login: iraquitan * File: settings * Date: 3/23/16 * Time: 12:16 AM """ # Replace the following lines with client IDs obtained from the APIs # Console or Cloud Console. WEB_CLIENT_ID = 'your-web-client-id'
Fix the placeholder for better understanding
fix: Fix the placeholder for better understanding
Python
mit
iraquitan/udacity-fsnd-p4-conference-app,iraquitan/udacity-fsnd-p4-conference-app,iraquitan/udacity-fsnd-p4-conference-app
68b52fedf5b22891a4fc9cf121417ced38d0ea00
rolepermissions/utils.py
rolepermissions/utils.py
from __future__ import unicode_literals import re import collections def user_is_authenticated(user): if isinstance(user.is_authenticated, collections.Callable): authenticated = user.is_authenticated() else: authenticated = user.is_authenticated return authenticated def camelToSnake(s): """ https://gist.github.com/jaytaylor/3660565 Is it ironic that this function is written in camel case, yet it converts to snake case? hmm.. """ _underscorer1 = re.compile(r'(.)([A-Z][a-z]+)') _underscorer2 = re.compile('([a-z0-9])([A-Z])') subbed = _underscorer1.sub(r'\1_\2', s) return _underscorer2.sub(r'\1_\2', subbed).lower() def snake_to_title(s): return ' '.join(x.capitalize() for x in s.split('_')) def camel_or_snake_to_title(s): return snake_to_title(camelToSnake(s))
from __future__ import unicode_literals import re try: from collections.abc import Callable except ImportError: from collections import Callable def user_is_authenticated(user): if isinstance(user.is_authenticated, Callable): authenticated = user.is_authenticated() else: authenticated = user.is_authenticated return authenticated def camelToSnake(s): """ https://gist.github.com/jaytaylor/3660565 Is it ironic that this function is written in camel case, yet it converts to snake case? hmm.. """ _underscorer1 = re.compile(r'(.)([A-Z][a-z]+)') _underscorer2 = re.compile('([a-z0-9])([A-Z])') subbed = _underscorer1.sub(r'\1_\2', s) return _underscorer2.sub(r'\1_\2', subbed).lower() def snake_to_title(s): return ' '.join(x.capitalize() for x in s.split('_')) def camel_or_snake_to_title(s): return snake_to_title(camelToSnake(s))
Fix import of Callable for Python 3.9
Fix import of Callable for Python 3.9 Python 3.3 moved Callable to collections.abc and Python 3.9 removes Callable from collections module
Python
mit
vintasoftware/django-role-permissions
7f7fd4e7547af3a6d7e3cd4da025c2b0ab24508b
widgy/contrib/widgy_mezzanine/migrations/0001_initial.py
widgy/contrib/widgy_mezzanine/migrations/0001_initial.py
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import widgy.db.fields import django.db.models.deletion import widgy.contrib.widgy_mezzanine.models class Migration(migrations.Migration): dependencies = [ ('pages', '__first__'), ('review_queue', '0001_initial'), ] operations = [ migrations.CreateModel( name='WidgyPage', fields=[ ('page_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='pages.Page')), ('root_node', widgy.db.fields.VersionedWidgyField(on_delete=django.db.models.deletion.SET_NULL, verbose_name='widgy content', to='review_queue.ReviewedVersionTracker', null=True)), ], options={ 'ordering': ('_order',), 'verbose_name': 'widgy page', 'verbose_name_plural': 'widgy pages', }, bases=(widgy.contrib.widgy_mezzanine.models.WidgyPageMixin, 'pages.page'), ), migrations.CreateModel( name='UndeletePage', fields=[ ], options={ 'ordering': ('_order',), 'verbose_name': 'restore deleted page', 'proxy': True, }, bases=('widgy_mezzanine.widgypage',), ), ]
# -*- coding: utf-8 -*- from __future__ import unicode_literals from django.db import models, migrations import widgy.db.fields import django.db.models.deletion import widgy.contrib.widgy_mezzanine.models class Migration(migrations.Migration): dependencies = [ ('pages', '__first__'), ('widgy', '0001_initial'), ] operations = [ migrations.CreateModel( name='WidgyPage', fields=[ ('page_ptr', models.OneToOneField(parent_link=True, auto_created=True, primary_key=True, serialize=False, to='pages.Page')), ('root_node', widgy.db.fields.VersionedWidgyField(on_delete=django.db.models.deletion.SET_NULL, verbose_name='widgy content', to='widgy.VersionTracker', null=True)), ], options={ 'ordering': ('_order',), 'verbose_name': 'widgy page', 'verbose_name_plural': 'widgy pages', }, bases=(widgy.contrib.widgy_mezzanine.models.WidgyPageMixin, 'pages.page'), ), migrations.CreateModel( name='UndeletePage', fields=[ ], options={ 'ordering': ('_order',), 'verbose_name': 'restore deleted page', 'proxy': True, }, bases=('widgy_mezzanine.widgypage',), ), ]
Remove dependency for ReviewedVersionTracker in migrations
Remove dependency for ReviewedVersionTracker in migrations The base widgy migrations had references to ReviewedVersionTracker, which is not part of the base widgy install. This commit changes the dependency to VersionTracker instead, which is part of the base widgy install.
Python
apache-2.0
j00bar/django-widgy,j00bar/django-widgy,j00bar/django-widgy
e9dc10532a0357bc90ebaa2655b36822f9249673
test/__init__.py
test/__init__.py
from cellulario import iocell import asyncio import uvloop asyncio.set_event_loop_policy(uvloop.EventLoopPolicy()) iocell.DEBUG = True
from cellulario import iocell iocell.DEBUG = True
Remove uvloop from test run.
Remove uvloop from test run.
Python
mit
mayfield/cellulario
16369ed6a11aaa39e94479b06ed78eb75f5b33e1
src/args.py
src/args.py
#!/usr/bin/env python3 # chameleon-crawler # # Copyright 2014 ghostwords. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from argparse import ArgumentParser from glob import glob from os import path def is_valid_file(f, parser): if path.isfile(f): return f else: return parser.optparser.error("%s does not exist!" % f) def parse_args(): parser = ArgumentParser() parser.add_argument("--non-headless", action="store_true", help="do not use a virtual display") parser.add_argument("--crx", metavar='CRX_FILE_PATH', action="store", type=lambda x: is_valid_file(x, parser), default=max(glob("*.crx"), key=path.getmtime), help="path to Chrome extension CRX package") return parser.parse_args()
#!/usr/bin/env python3 # chameleon-crawler # # Copyright 2014 ghostwords. # # This Source Code Form is subject to the terms of the Mozilla Public # License, v. 2.0. If a copy of the MPL was not distributed with this # file, You can obtain one at http://mozilla.org/MPL/2.0/. from glob import glob from os import path import argparse def is_valid_file(f, parser): if path.isfile(f): return f raise argparse.ArgumentTypeError("%s does not exist!" % f) def parse_args(): parser = argparse.ArgumentParser() parser.add_argument("--non-headless", action="store_true", help="do not use a virtual display") parser.add_argument("--crx", metavar='CRX_FILE_PATH', action="store", type=lambda x: is_valid_file(x, parser), default=max(glob("*.crx"), key=path.getmtime), help="path to Chrome extension CRX package") return parser.parse_args()
Fix --crx arg error reporting.
Fix --crx arg error reporting.
Python
mpl-2.0
ghostwords/chameleon-crawler,ghostwords/chameleon-crawler,ghostwords/chameleon-crawler
78675420e9d23d9978f68ed002de0fc1284d3d0c
node.py
node.py
class Node(object): def __init__(self): # Node(s) from which this Node receives values self.inbound_nodes = inbound_nodes # Node(s) to which this Node passes values self.outbound_nodes = [] # For each inbound Node here, add this Node as an outbound to that Node. for n in self.inbound_nodes: n.outbound_nodes.append(self) # A calculated value self.value = None
class Node(object): def __init__(self): # Node(s) from which this Node receives values self.inbound_nodes = inbound_nodes # Node(s) to which this Node passes values self.outbound_nodes = [] # For each inbound Node here, add this Node as an outbound to that Node. for n in self.inbound_nodes: n.outbound_nodes.append(self) # A calculated value self.value = None def forward(self): """ Forward propagation. Compute the output value based on `inbound_nodes` and store the result in self.value. """ raise NotImplemented
Add forward function declaration to Class Node
Add forward function declaration to Class Node
Python
mit
YabinHu/miniflow
238578d41beec33d7428cb53d79fc21c028cfc87
tests/specifications/external_spec_test.py
tests/specifications/external_spec_test.py
from fontbakery.checkrunner import Section from fontbakery.fonts_spec import spec_factory def check_filter(checkid, font=None, **iterargs): if checkid in ( "com.google.fonts/check/035", # ftxvalidator "com.google.fonts/check/036", # ots-sanitize "com.google.fonts/check/037", # Font Validator "com.google.fonts/check/038", # Fontforge "com.google.fonts/check/039", # Fontforge ): return False, "Skipping external tools." return True, None def test_external_specification(): """Test the creation of external specifications.""" specification = spec_factory(default_section=Section("Dalton Maag OpenType")) specification.set_check_filter(check_filter) specification.auto_register( globals(), spec_imports=["fontbakery.specifications.opentype"]) # Probe some tests expected_tests = ["com.google.fonts/check/002", "com.google.fonts/check/180"] specification.test_expected_checks(expected_tests) # Probe tests we don't want assert "com.google.fonts/check/035" not in specification._check_registry.keys() assert len(specification.sections) > 1
from fontbakery.checkrunner import Section from fontbakery.fonts_spec import spec_factory def check_filter(item_type, item_id, item): if item_type == "check" and item_id in ( "com.google.fonts/check/035", # ftxvalidator "com.google.fonts/check/036", # ots-sanitize "com.google.fonts/check/037", # Font Validator "com.google.fonts/check/038", # Fontforge "com.google.fonts/check/039", # Fontforge ): return False return True def test_external_specification(): """Test the creation of external specifications.""" specification = spec_factory(default_section=Section("Dalton Maag OpenType")) specification.auto_register( globals(), spec_imports=["fontbakery.specifications.opentype"], filter_func=check_filter) # Probe some tests expected_tests = ["com.google.fonts/check/002", "com.google.fonts/check/171"] specification.test_expected_checks(expected_tests) # Probe tests we don't want assert "com.google.fonts/check/035" not in specification._check_registry.keys() assert len(specification.sections) > 1
Use auto_register's filter_func to filter tests
Use auto_register's filter_func to filter tests
Python
apache-2.0
moyogo/fontbakery,moyogo/fontbakery,googlefonts/fontbakery,googlefonts/fontbakery,moyogo/fontbakery,graphicore/fontbakery,graphicore/fontbakery,graphicore/fontbakery,googlefonts/fontbakery
a7be90536618ac52c91f599bb167e05f831cddfb
mangopaysdk/entities/transaction.py
mangopaysdk/entities/transaction.py
from mangopaysdk.entities.entitybase import EntityBase from mangopaysdk.types.money import Money class Transaction (EntityBase): """Transaction entity. Base class for: PayIn, PayOut, Transfer. """ def __init__(self, id = None): self.AuthorId = None self.CreditedUserId = None # Money self.DebitedFunds = None # Money self.CreditedFunds = None # Money self.Fees = None # TransactionType {PAYIN, PAYOUT, TRANSFER} self.Type = None # TransactionNature {REGULAR, REFUND, REPUDIATION} self.Nature = None # TransactionStatus {CREATED, SUCCEEDED, FAILED} self.Status = None self.ResultCode = None # timestamp self.ExecutionDate = None return super(Transaction, self).__init__(id) def GetSubObjects(self): return { 'DebitedFunds': 'Money' , 'CreditedFunds': 'Money' , 'Fees': 'Money' } def GetReadOnlyProperties(self): properties = super(Transaction, self).GetReadOnlyProperties() properties.append('Status' ) properties.append('ResultCode' ) properties.append('ExecutionDate' ) return properties
from mangopaysdk.entities.entitybase import EntityBase from mangopaysdk.types.money import Money class Transaction (EntityBase): """Transaction entity. Base class for: PayIn, PayOut, Transfer. """ def __init__(self, id = None): self.AuthorId = None self.CreditedUserId = None # Money self.DebitedFunds = None # Money self.CreditedFunds = None # Money self.Fees = None # TransactionType {PAYIN, PAYOUT, TRANSFER} self.Type = None # TransactionNature {REGULAR, REFUND, REPUDIATION} self.Nature = None # TransactionStatus {CREATED, SUCCEEDED, FAILED} self.Status = None self.ResultCode = None self.ResultMessage = None # timestamp self.ExecutionDate = None return super(Transaction, self).__init__(id) def GetSubObjects(self): return { 'DebitedFunds': 'Money' , 'CreditedFunds': 'Money' , 'Fees': 'Money' } def GetReadOnlyProperties(self): properties = super(Transaction, self).GetReadOnlyProperties() properties.append('Status' ) properties.append('ResultCode' ) properties.append('ExecutionDate' ) return properties
Add possibilty to get ResultMessage
Add possibilty to get ResultMessage
Python
mit
chocopoche/mangopay2-python-sdk,Mangopay/mangopay2-python-sdk
1a9c5c6cee3b8c31d92ab0949fc312907adf6611
swf/core.py
swf/core.py
# -*- coding:utf-8 -*- # Copyright (c) 2013, Theo Crevon # Copyright (c) 2013, Greg Leclercq # # See the file LICENSE for copying permission. import boto.swf from . import settings SETTINGS = settings.get() class ConnectedSWFObject(object): """Authenticated object interface Provides the instance attributes: - `region`: name of the AWS region - `connection`: to the SWF endpoint (`boto.swf.layer1.Layer1` object): """ __slots__ = [ 'region', 'connection' ] def __init__(self, *args, **kwargs): settings_ = {k: v for k, v in SETTINGS.iteritems()} settings_.update(kwargs) self.region = (settings_.pop('region') or boto.swf.layer1.Layer1.DefaultRegionName) self.connection = boto.swf.connect_to_region(self.region, **settings_) if self.connection is None: raise ValueError('invalid region: {}'.format(self.region))
# -*- coding:utf-8 -*- # Copyright (c) 2013, Theo Crevon # Copyright (c) 2013, Greg Leclercq # # See the file LICENSE for copying permission. import boto.swf from . import settings SETTINGS = settings.get() class ConnectedSWFObject(object): """Authenticated object interface Provides the instance attributes: - `region`: name of the AWS region - `connection`: to the SWF endpoint (`boto.swf.layer1.Layer1` object): """ __slots__ = [ 'region', 'connection' ] def __init__(self, *args, **kwargs): settings_ = {k: v for k, v in SETTINGS.iteritems()} settings_.update(kwargs) self.region = (settings_.pop('region', None) or boto.swf.layer1.Layer1.DefaultRegionName) self.connection = boto.swf.connect_to_region(self.region, **settings_) if self.connection is None: raise ValueError('invalid region: {}'.format(self.region))
Fix ConnectedSWFObject: pass default value to pop()
Fix ConnectedSWFObject: pass default value to pop()
Python
mit
botify-labs/python-simple-workflow,botify-labs/python-simple-workflow
3cacced39d9cb8bd5d6a2b3db8aa4b5aa1b37f58
jaraco/util/meta.py
jaraco/util/meta.py
""" meta.py Some useful metaclasses. """ from __future__ import unicode_literals class LeafClassesMeta(type): """ A metaclass for classes that keeps track of all of them that aren't base classes. """ _leaf_classes = set() def __init__(cls, name, bases, attrs): if not hasattr(cls, '_leaf_classes'): cls._leaf_classes = set() leaf_classes = getattr(cls, '_leaf_classes') leaf_classes.add(cls) # remove any base classes leaf_classes -= set(bases) class TagRegistered(type): """ As classes of this metaclass are created, they keep a registry in the base class of all classes by a class attribute, 'tag'. """ def __init__(cls, name, bases, namespace): super(TagRegistered, cls).__init__(name, bases, namespace) if not hasattr(cls, '_registry'): cls._registry = {} attr = getattr(cls, 'tag', None) if attr: cls._registry[attr] = cls
""" meta.py Some useful metaclasses. """ from __future__ import unicode_literals class LeafClassesMeta(type): """ A metaclass for classes that keeps track of all of them that aren't base classes. """ _leaf_classes = set() def __init__(cls, name, bases, attrs): if not hasattr(cls, '_leaf_classes'): cls._leaf_classes = set() leaf_classes = getattr(cls, '_leaf_classes') leaf_classes.add(cls) # remove any base classes leaf_classes -= set(bases) class TagRegistered(type): """ As classes of this metaclass are created, they keep a registry in the base class of all classes by a class attribute, indicated by attr_name. """ attr_name = 'tag' def __init__(cls, name, bases, namespace): super(TagRegistered, cls).__init__(name, bases, namespace) if not hasattr(cls, '_registry'): cls._registry = {} meta = cls.__class__ attr = getattr(cls, meta.attr_name, None) if attr: cls._registry[attr] = cls
Allow attribute to be customized in TagRegistered
Allow attribute to be customized in TagRegistered
Python
mit
jaraco/jaraco.classes
7b6838ea292e011f96f5212992d00c1009e1f6b2
examples/gitter_example.py
examples/gitter_example.py
# -*- coding: utf-8 -*- from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer from settings import GITTER # Uncomment the following lines to enable verbose logging # import logging # logging.basicConfig(level=logging.INFO) chatbot = ChatBot( 'GitterBot', gitter_room=GITTER['ROOM'], gitter_api_token=GITTER['API_TOKEN'], gitter_only_respond_to_mentions=False, input_adapter='chatterbot.input.Gitter', output_adapter='chatterbot.output.Gitter' ) trainer = ChatterBotCorpusTrainer(chatbot) trainer.train('chatterbot.corpus.english') # The following loop will execute each time the user enters input while True: try: response = chatbot.get_response(None) # Press ctrl-c or ctrl-d on the keyboard to exit except (KeyboardInterrupt, EOFError, SystemExit): break
# -*- coding: utf-8 -*- from chatterbot import ChatBot from chatterbot.trainers import ChatterBotCorpusTrainer from settings import GITTER # Uncomment the following lines to enable verbose logging # import logging # logging.basicConfig(level=logging.INFO) ''' To use this example, create a new file called settings.py. In settings.py define the following: GITTER = { "API_TOKEN": "my-api-token", "ROOM": "example_project/test_room" } ''' chatbot = ChatBot( 'GitterBot', gitter_room=GITTER['ROOM'], gitter_api_token=GITTER['API_TOKEN'], gitter_only_respond_to_mentions=False, input_adapter='chatterbot.input.Gitter', output_adapter='chatterbot.output.Gitter' ) trainer = ChatterBotCorpusTrainer(chatbot) trainer.train('chatterbot.corpus.english') # The following loop will execute each time the user enters input while True: try: response = chatbot.get_response(None) # Press ctrl-c or ctrl-d on the keyboard to exit except (KeyboardInterrupt, EOFError, SystemExit): break
Add better instructions to the Gitter example
Add better instructions to the Gitter example
Python
bsd-3-clause
gunthercox/ChatterBot,vkosuri/ChatterBot
260a5601a9b2990374d2f97d92898236e0b9342e
tests/profiling_test_script.py
tests/profiling_test_script.py
#!/usr/bin/python # -*- coding: utf-8 -*- u""" :author: Joseph Martinot-Lagarde Created on Sat Jan 19 14:57:57 2013 """ from __future__ import ( print_function, division, unicode_literals, absolute_import) import subdir.profiling_test_script2 as script2 @profile def fact(n): result = 1 for i in xrange(2, n + 1): result *= i return result @profile def sum_(n): result = 0 for i in xrange(1, n + 1): result += i return result if __name__ == "__main__": print(fact(120)) print(sum_(120)) print(script2.fact2(120)) print(script2.sum2(120))
#!/usr/bin/python # -*- coding: utf-8 -*- u""" :author: Joseph Martinot-Lagarde Created on Sat Jan 19 14:57:57 2013 """ from __future__ import ( print_function, division, unicode_literals, absolute_import) import subdir.profiling_test_script2 as script2 @profile def fact(n): result = 1 for i in xrange(2, n // 4): result *= i result = 1 for i in xrange(2, n // 16): result *= i result = 1 for i in xrange(2, n + 1): result *= i return result @profile def sum_(n): result = 0 for i in xrange(1, n + 1): result += i return result if __name__ == "__main__": print(fact(120)) print(sum_(120)) print(script2.fact2(120)) print(script2.sum2(120))
Add diversity to test script
Add diversity to test script
Python
mit
jitseniesen/spyder-memory-profiler,jitseniesen/spyder-memory-profiler,Nodd/spyder_line_profiler,spyder-ide/spyder.line_profiler,spyder-ide/spyder.memory_profiler,spyder-ide/spyder.line-profiler,Nodd/spyder.line_profiler
c0db57b52aa0546fd6f7a2cf4fc0242cbcf76537
test_bot.py
test_bot.py
#!/usr/bin/env python from tpb import TPB t = TPB() # when using a proxy site # t = TPB('http://uberproxy.net/thepiratebay.sx') for to in t.get_recent_torrents(): print '*' * 50 to.print_torrent() print '\n' """ # search for programming ebooks results = t.search('hello world', category=601) for r in results: print '*' * 50 r.print_torrent() print '\n' """
#!/usr/bin/env python from tpb import TPB t = TPB() # when using a proxy site # t = TPB(domain='http://uberproxy.net/thepiratebay.sx') for to in t.get_recent_torrents(): print '*' * 50 to.print_torrent() print '\n' """ # search for programming ebooks results = t.search('hello world', category=601) for r in results: print '*' * 50 r.print_torrent() print '\n' """
Fix the test bot's TPB initialization
Fix the test bot's TPB initialization
Python
mit
karan/TPB,karan/TPB
97a67e022d094743e806896386bdbe317cb56fb6
gitcloner.py
gitcloner.py
#! /usr/bin/env python3 import sys from gitaccount import GitAccount def main(): if len(sys.argv) < 2: print("""Usage: gitcloner.py [OPTION] [NAME] OPTIONS: -u - for user repositories -o - for organization repositories NAME: Username or Organization Name """) sys.exit(1) args = sys.argv[1:3] repoType, name = args if repoType == '-u': repoType = 'user' elif repoType == '-o': repoType = 'org' else: raise ValueError() account = GitAccount(repoType, name) account.cloneRepos() if __name__ == '__main__': main()
#! /usr/bin/env python3 import sys import argparse from gitaccount import GitAccount def main(): parser = argparse.ArgumentParser( prog='gitcloner', description='Clone all the repositories from a github user/org\naccount to the current directory') group = parser.add_mutually_exclusive_group() group.add_argument('-u', '--user', help='For user accounts [DEFAULT]', action='store_true') group.add_argument('-o', '--org', help='For organization accounts', action='store_true') parser.add_argument('name', help='name of the user / organization') args = parser.parse_args() if not(args.user or args.org): args.user = True print('Default account type is user account') if args.user: print('Username: {}'.format(args.name)) accType = 'user' else: print('Organization: {}'.format(args.name)) accType = 'org' account = GitAccount(accType, args.name) account.cloneRepos() if __name__ == '__main__': main()
Use argparse instead of sys.argv
Use argparse instead of sys.argv
Python
mit
shakib609/gitcloner
d42b9da06d5cde89a6116d711fc6ae216256cabc
shell/view/home/IconLayout.py
shell/view/home/IconLayout.py
import random class IconLayout: def __init__(self, width, height): self._icons = [] self._width = width self._height = height def add_icon(self, icon): self._icons.append(icon) self._layout_icon(icon) def remove_icon(self, icon): self._icons.remove(icon) def _is_valid_position(self, icon, x, y): icon_size = icon.props.size border = 20 if not (border < x < self._width - icon_size - border and \ border < y < self._height - icon_size - border): return False return True def _layout_icon(self, icon): while True: x = random.random() * self._width y = random.random() * self._height if self._is_valid_position(icon, x, y): break icon.props.x = x icon.props.y = y
import random class IconLayout: def __init__(self, width, height): self._icons = [] self._width = width self._height = height def add_icon(self, icon): self._icons.append(icon) self._layout_icon(icon) def remove_icon(self, icon): self._icons.remove(icon) def _is_valid_position(self, icon, x, y): icon_size = icon.get_property('size') border = 20 if not (border < x < self._width - icon_size - border and \ border < y < self._height - icon_size - border): return False return True def _layout_icon(self, icon): while True: x = random.random() * self._width y = random.random() * self._height if self._is_valid_position(icon, x, y): break icon.set_property('x', x) icon.set_property('y', y)
Use get/set_property rather than direct accessors
Use get/set_property rather than direct accessors
Python
lgpl-2.1
Daksh/sugar-toolkit-gtk3,manuq/sugar-toolkit-gtk3,tchx84/sugar-toolkit-gtk3,quozl/sugar-toolkit-gtk3,tchx84/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,puneetgkaur/backup_sugar_sugartoolkit,quozl/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit,tchx84/debian-pkg-sugar-toolkit,ceibal-tatu/sugar-toolkit,gusDuarte/sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit,tchx84/debian-pkg-sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit-gtk3,manuq/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,puneetgkaur/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit,i5o/sugar-toolkit-gtk3,Daksh/sugar-toolkit-gtk3,godiard/sugar-toolkit-gtk3,tchx84/debian-pkg-sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit,gusDuarte/sugar-toolkit-gtk3,puneetgkaur/sugar-toolkit-gtk3,quozl/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,i5o/sugar-toolkit-gtk3,Daksh/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,puneetgkaur/sugar-toolkit-gtk3,samdroid-apps/sugar-toolkit-gtk3,gusDuarte/sugar-toolkit-gtk3,gusDuarte/sugar-toolkit-gtk3,ceibal-tatu/sugar-toolkit-gtk3,sugarlabs/sugar-toolkit,sugarlabs/sugar-toolkit,sugarlabs/sugar-toolkit-gtk3,quozl/sugar-toolkit-gtk3,manuq/sugar-toolkit-gtk3,puneetgkaur/backup_sugar_sugartoolkit,puneetgkaur/backup_sugar_sugartoolkit,sugarlabs/sugar-toolkit,ceibal-tatu/sugar-toolkit,tchx84/sugar-toolkit-gtk3
161cd07fca220494e675b1da674dbf57254a28b3
scripts/spat_gencomms.py
scripts/spat_gencomms.py
import spat_community_generation as sg import sys Svals = [10, 11, 13, 14, 16, 18, 21, 23, 26, 30, 34, 38, 43, 48, 55, 62, 70, 78, 89, 100] Nvals = [120, 186, 289, 447, 694, 1076, 1668, 2587, 4011, 6220, 9646, 14957, 23193, 35965, 55769, 86479, 134099, 207941, 322444, 500000] if len(sys.argv) > 1: Sindex = int(sys.argv[1]) Svals = Svals[Sindex] sg.explore_parameter_space(Svals, Nvals, 200, 12)
import spat_community_generation as sg import sys Svals = [10, 11, 13, 14, 16, 18, 21, 23, 26, 30, 34, 38, 43, 48, 55, 62, 70, 78, 89, 100] Nvals = [120, 186, 289, 447, 694, 1076, 1668, 2587, 4011, 6220, 9646, 14957, 23193, 35965, 55769, 86479, 134099, 207941, 322444, 500000] if len(sys.argv) > 1: Sindex = int(sys.argv[1]) Svals = [Svals[Sindex]] sg.explore_parameter_space(Svals, Nvals, 200, 12)
Change to ensure that the Svals were handled as a list
Change to ensure that the Svals were handled as a list
Python
mit
weecology/mete-spatial,weecology/mete-spatial,weecology/mete-spatial,weecology/mete-spatial
911094754fc908d99009c5cfec22ac9033ffd472
my_account_helper/model/__init__.py
my_account_helper/model/__init__.py
# -*- encoding: utf-8 -*- ############################################################################## # # Copyright (C) 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 . import xmlrpc_helper
# -*- encoding: utf-8 -*- ############################################################################## # # Copyright (C) 2015 Compassion CH (http://www.compassion.ch) # Releasing children from poverty in Jesus' name # @author: Emmanuel Mathier <[email protected]> # # The licence is in the file __openerp__.py # ############################################################################## from . import xmlrpc_helper
Fix comment header on init
Fix comment header on init
Python
agpl-3.0
Secheron/compassion-switzerland,CompassionCH/compassion-switzerland,eicher31/compassion-switzerland,eicher31/compassion-switzerland,CompassionCH/compassion-switzerland,Secheron/compassion-switzerland,CompassionCH/compassion-switzerland,ecino/compassion-switzerland,MickSandoz/compassion-switzerland,ecino/compassion-switzerland,ecino/compassion-switzerland,ndtran/compassion-switzerland,MickSandoz/compassion-switzerland,ndtran/compassion-switzerland,eicher31/compassion-switzerland
5c61d7f125078cb6b3bd0c5700ae9219baab0078
webapp/tests/test_dashboard.py
webapp/tests/test_dashboard.py
from django.core.urlresolvers import reverse from django.test import TestCase class DashboardTest(TestCase): def test_dashboard(self): url = reverse('graphite.dashboard.views.dashboard') response = self.client.get(url) self.assertEqual(response.status_code, 200)
from django.core.urlresolvers import reverse from django.test import TestCase class DashboardTest(TestCase): def test_dashboard(self): url = reverse('dashboard') response = self.client.get(url) self.assertEqual(response.status_code, 200)
Update reverse call to use named URL
Update reverse call to use named URL
Python
apache-2.0
redice/graphite-web,dbn/graphite-web,Skyscanner/graphite-web,penpen/graphite-web,lyft/graphite-web,esnet/graphite-web,bpaquet/graphite-web,atnak/graphite-web,section-io/graphite-web,kkdk5535/graphite-web,cosm0s/graphite-web,cgvarela/graphite-web,gwaldo/graphite-web,redice/graphite-web,edwardmlyte/graphite-web,atnak/graphite-web,criteo-forks/graphite-web,bmhatfield/graphite-web,obfuscurity/graphite-web,AICIDNN/graphite-web,edwardmlyte/graphite-web,gwaldo/graphite-web,penpen/graphite-web,cbowman0/graphite-web,Skyscanner/graphite-web,JeanFred/graphite-web,cgvarela/graphite-web,bruce-lyft/graphite-web,criteo-forks/graphite-web,phreakocious/graphite-web,lyft/graphite-web,mcoolive/graphite-web,piotr1212/graphite-web,esnet/graphite-web,zBMNForks/graphite-web,axibase/graphite-web,blacked/graphite-web,AICIDNN/graphite-web,kkdk5535/graphite-web,atnak/graphite-web,ZelunZhang/graphite-web,graphite-server/graphite-web,cgvarela/graphite-web,graphite-server/graphite-web,zBMNForks/graphite-web,synedge/graphite-web,pu239ppy/graphite-web,axibase/graphite-web,gwaldo/graphite-web,jssjr/graphite-web,esnet/graphite-web,Skyscanner/graphite-web,bmhatfield/graphite-web,DanCech/graphite-web,lfckop/graphite-web,JeanFred/graphite-web,edwardmlyte/graphite-web,brutasse/graphite-web,esnet/graphite-web,Invoca/graphite-web,johnseekins/graphite-web,esnet/graphite-web,criteo-forks/graphite-web,mcoolive/graphite-web,pu239ppy/graphite-web,bmhatfield/graphite-web,edwardmlyte/graphite-web,ZelunZhang/graphite-web,DanCech/graphite-web,section-io/graphite-web,penpen/graphite-web,cbowman0/graphite-web,Invoca/graphite-web,markolson/graphite-web,markolson/graphite-web,Aloomaio/graphite-web,graphite-project/graphite-web,mcoolive/graphite-web,edwardmlyte/graphite-web,atnak/graphite-web,graphite-project/graphite-web,Squarespace/graphite-web,cbowman0/graphite-web,kkdk5535/graphite-web,lyft/graphite-web,criteo-forks/graphite-web,JeanFred/graphite-web,redice/graphite-web,graphite-server/graphite-web,dbn/graphite-web,pu239ppy/graphite-web,piotr1212/graphite-web,brutasse/graphite-web,phreakocious/graphite-web,mcoolive/graphite-web,lfckop/graphite-web,penpen/graphite-web,DanCech/graphite-web,johnseekins/graphite-web,blacked/graphite-web,bpaquet/graphite-web,cbowman0/graphite-web,cgvarela/graphite-web,markolson/graphite-web,bpaquet/graphite-web,graphite-project/graphite-web,bpaquet/graphite-web,bruce-lyft/graphite-web,Invoca/graphite-web,Squarespace/graphite-web,lyft/graphite-web,synedge/graphite-web,bbc/graphite-web,piotr1212/graphite-web,pu239ppy/graphite-web,johnseekins/graphite-web,JeanFred/graphite-web,DanCech/graphite-web,obfuscurity/graphite-web,lyft/graphite-web,cosm0s/graphite-web,Invoca/graphite-web,deniszh/graphite-web,krux/graphite-web,bbc/graphite-web,goir/graphite-web,Squarespace/graphite-web,DanCech/graphite-web,Aloomaio/graphite-web,bpaquet/graphite-web,johnseekins/graphite-web,disqus/graphite-web,penpen/graphite-web,section-io/graphite-web,cgvarela/graphite-web,lfckop/graphite-web,Invoca/graphite-web,jssjr/graphite-web,AICIDNN/graphite-web,bruce-lyft/graphite-web,cosm0s/graphite-web,ZelunZhang/graphite-web,graphite-project/graphite-web,zBMNForks/graphite-web,cgvarela/graphite-web,JeanFred/graphite-web,piotr1212/graphite-web,goir/graphite-web,cbowman0/graphite-web,drax68/graphite-web,criteo-forks/graphite-web,synedge/graphite-web,synedge/graphite-web,nkhuyu/graphite-web,JeanFred/graphite-web,phreakocious/graphite-web,Aloomaio/graphite-web,bbc/graphite-web,phreakocious/graphite-web,cosm0s/graphite-web,phreakocious/graphite-web,brutasse/graphite-web,graphite-server/graphite-web,Squarespace/graphite-web,gwaldo/graphite-web,cosm0s/graphite-web,deniszh/graphite-web,pu239ppy/graphite-web,blacked/graphite-web,Invoca/graphite-web,krux/graphite-web,AICIDNN/graphite-web,redice/graphite-web,piotr1212/graphite-web,cbowman0/graphite-web,section-io/graphite-web,obfuscurity/graphite-web,redice/graphite-web,section-io/graphite-web,deniszh/graphite-web,krux/graphite-web,nkhuyu/graphite-web,gwaldo/graphite-web,nkhuyu/graphite-web,graphite-server/graphite-web,deniszh/graphite-web,goir/graphite-web,Aloomaio/graphite-web,drax68/graphite-web,markolson/graphite-web,krux/graphite-web,obfuscurity/graphite-web,dbn/graphite-web,bruce-lyft/graphite-web,markolson/graphite-web,bmhatfield/graphite-web,brutasse/graphite-web,atnak/graphite-web,Skyscanner/graphite-web,krux/graphite-web,blacked/graphite-web,kkdk5535/graphite-web,jssjr/graphite-web,goir/graphite-web,lfckop/graphite-web,bmhatfield/graphite-web,cosm0s/graphite-web,Squarespace/graphite-web,disqus/graphite-web,ZelunZhang/graphite-web,Aloomaio/graphite-web,axibase/graphite-web,disqus/graphite-web,bbc/graphite-web,ZelunZhang/graphite-web,redice/graphite-web,goir/graphite-web,bruce-lyft/graphite-web,ZelunZhang/graphite-web,AICIDNN/graphite-web,axibase/graphite-web,mcoolive/graphite-web,disqus/graphite-web,johnseekins/graphite-web,drax68/graphite-web,drax68/graphite-web,lyft/graphite-web,graphite-project/graphite-web,lfckop/graphite-web,bmhatfield/graphite-web,blacked/graphite-web,axibase/graphite-web,axibase/graphite-web,krux/graphite-web,disqus/graphite-web,drax68/graphite-web,bbc/graphite-web,criteo-forks/graphite-web,pu239ppy/graphite-web,obfuscurity/graphite-web,nkhuyu/graphite-web,drax68/graphite-web,jssjr/graphite-web,obfuscurity/graphite-web,kkdk5535/graphite-web,jssjr/graphite-web,bruce-lyft/graphite-web,Aloomaio/graphite-web,kkdk5535/graphite-web,zBMNForks/graphite-web,DanCech/graphite-web,dbn/graphite-web,Squarespace/graphite-web,AICIDNN/graphite-web,zBMNForks/graphite-web,section-io/graphite-web,mcoolive/graphite-web,edwardmlyte/graphite-web,synedge/graphite-web,graphite-project/graphite-web,atnak/graphite-web,nkhuyu/graphite-web,brutasse/graphite-web,jssjr/graphite-web,disqus/graphite-web,johnseekins/graphite-web,synedge/graphite-web,Skyscanner/graphite-web,Skyscanner/graphite-web,lfckop/graphite-web,zBMNForks/graphite-web,deniszh/graphite-web,nkhuyu/graphite-web,penpen/graphite-web,dbn/graphite-web,blacked/graphite-web,brutasse/graphite-web,deniszh/graphite-web,graphite-server/graphite-web,bpaquet/graphite-web,gwaldo/graphite-web,goir/graphite-web,phreakocious/graphite-web,piotr1212/graphite-web,dbn/graphite-web