commit stringlengths 40 40 | old_file stringlengths 4 150 | new_file stringlengths 4 150 | old_contents stringlengths 0 3.26k | new_contents stringlengths 1 4.43k | subject stringlengths 15 501 | message stringlengths 15 4.06k | lang stringclasses 4
values | license stringclasses 13
values | repos stringlengths 5 91.5k | diff stringlengths 0 4.35k |
|---|---|---|---|---|---|---|---|---|---|---|
727f221767c662e95585f54e06c0c8b4e4a77d88 | smartfile/exceptions.py | smartfile/exceptions.py | from requests.exceptions import ConnectionError
class SmartFileException(Exception):
pass
class SmartFileConnException(SmartFileException):
""" Exception for issues regarding a request. """
def __init__(self, exc, *args, **kwargs):
self.exc = exc
if isinstance(exc, ConnectionError):
... | from requests.exceptions import ConnectionError
class SmartFileException(Exception):
pass
class SmartFileConnException(SmartFileException):
""" Exception for issues regarding a request. """
def __init__(self, exc, *args, **kwargs):
self.exc = exc
if isinstance(exc, ConnectionError):
... | Handle responses without JSON or detail field | Handle responses without JSON or detail field
Check the response for JSON and a detail field before trying to access
them within SmartFileResponseException. This could occur if the server
returns a 500.
| Python | mit | smartfile/client-python | ---
+++
@@ -12,7 +12,7 @@
if isinstance(exc, ConnectionError):
self.detail = exc.message.strerror
else:
- self.detail = '{0}: {1}'.format(exc.__class__, exc)
+ self.detail = u'{0}: {1}'.format(exc.__class__, exc)
super(SmartFileConnException, self).__init_... |
1364470725a55232556d8856be7eb910f3376fb3 | permuta/misc/union_find.py | permuta/misc/union_find.py |
class UnionFind(object):
"""A collection of distjoint sets."""
def __init__(self, n = 0):
"""Creates a collection of n disjoint unit sets."""
self.p = [-1]*n
self.leaders = set( i for i in range(n) )
def find(self, x):
"""Return the identifier of a representative element f... |
class UnionFind(object):
"""A collection of distjoint sets."""
def __init__(self, n = 0):
"""Creates a collection of n disjoint unit sets."""
self.p = [-1]*n
self.leaders = set( i for i in range(n) )
def find(self, x):
"""Return the identifier of a representative element f... | Make UnionFind.unite return whether the operation was successful | Make UnionFind.unite return whether the operation was successful
| Python | bsd-3-clause | PermutaTriangle/Permuta | ---
+++
@@ -26,12 +26,13 @@
x = self.find(x)
y = self.find(y)
if x == y:
- return
+ return False
if self.size(x) > self.size(y):
x,y = y,x
self.p[y] += self.p[x]
self.p[x] = y
self.leaders.remove(x)
+ return True
... |
c90e9798881630c2f956e08901f5bd35d948df6d | salt_observer/management/commands/fetchpackages.py | salt_observer/management/commands/fetchpackages.py | from django.core.management.base import BaseCommand
from django.utils import timezone
from salt_observer.models import Minion
from . import ApiCommand
import json
class Command(ApiCommand, BaseCommand):
help = 'Fetch and save new data from all servers'
def save_packages(self, api):
print('Fetching ... | from django.core.management.base import BaseCommand
from django.utils import timezone
from salt_observer.models import Minion
from . import ApiCommand
import json
class Command(ApiCommand, BaseCommand):
help = 'Fetch and save new data from all servers'
def save_packages(self, api):
packages = api.g... | Remove unwanted prints in management command | Remove unwanted prints in management command
| Python | mit | hs-hannover/salt-observer,hs-hannover/salt-observer,hs-hannover/salt-observer | ---
+++
@@ -11,14 +11,10 @@
help = 'Fetch and save new data from all servers'
def save_packages(self, api):
- print('Fetching packages ...')
packages = api.get_server_module_data('pkg.list_pkgs')
- print('Fetching upgrades ...')
upgrades = api.get_server_module_data('pkg.li... |
fb488a27b16943709327c7a9f31c26aba418055f | lyricist/bsopener.py | lyricist/bsopener.py | from bs4 import BeautifulSoup
from urllib.request import urlopen
from urllib.request import Request
from .const import constant
class BSOpener(object):
""" A wrapper arround urllib and BeautifulSoup used a helper for url requests """
# TODO: make this class a singleton
class _Const():
""" Contains... | from bs4 import BeautifulSoup
from urllib.request import urlopen
from urllib.request import Request
from .const import constant
class BSOpener(object):
""" A wrapper arround urllib and BeautifulSoup used a helper for url requests """
# TODO: make this class a singleton
class _Const():
""" Contains... | Add handler for case of HTTP errors case. | Add handler for case of HTTP errors case.
Added a try/catch to url requests to handle errors.
| Python | mit | iluxonchik/lyricist | ---
+++
@@ -24,4 +24,10 @@
headers=self.CONST.HEADERS
req = Request(url=url, headers=headers)
- return BeautifulSoup(urlopen(req), "html.parser")
+ try:
+ html = urlopen(req)
+ except urllib.error.HTTPError:
+ print("WARNING: exception during opening ... |
a39a91b406be3965addc613021f0c94007c42cf6 | matchzoo/__init__.py | matchzoo/__init__.py | from pathlib import Path
USER_DIR = Path.expanduser(Path('~')).joinpath('.matchzoo')
if not USER_DIR.exists():
USER_DIR.mkdir()
USER_DATA_DIR = USER_DIR.joinpath('datasets')
if not USER_DATA_DIR.exists():
USER_DATA_DIR.mkdir()
from .logger import logger
from .version import __version__
from .utils import *
f... | from pathlib import Path
USER_DIR = Path.expanduser(Path('~')).joinpath('.matchzoo')
if not USER_DIR.exists():
USER_DIR.mkdir()
USER_DATA_DIR = USER_DIR.joinpath('datasets')
if not USER_DATA_DIR.exists():
USER_DATA_DIR.mkdir()
from .logger import logger
from .version import __version__
from .utils import *
f... | Add callbacks to matchzoo root scope. | Add callbacks to matchzoo root scope.
| Python | apache-2.0 | faneshion/MatchZoo,faneshion/MatchZoo | ---
+++
@@ -36,3 +36,4 @@
from .engine import load_model
from .engine import load_preprocessor
+from .engine import callbacks |
67c58e3941491d276318daf568354f1e17ef3892 | omics/gsa/__init__.py | omics/gsa/__init__.py | """Gene Set Analysis Module
"""
from GeneSetCollection import GeneSetCollection
| """Gene Set Analysis Module
"""
from GeneSetCollection import GeneSetCollect
def enrichment(gene_list, gene_set, background, alternative="two-sided", verbose=True):
"""Gene set enrichment analysis by Fisher Exact Test.
gene_list : query gene list
gene_set : predefined gene set
background : back... | Add enrichment function in gsa module | Add enrichment function in gsa module
| Python | mit | choyichen/omics | ---
+++
@@ -1,3 +1,35 @@
"""Gene Set Analysis Module
"""
-from GeneSetCollection import GeneSetCollection
+from GeneSetCollection import GeneSetCollect
+
+def enrichment(gene_list, gene_set, background, alternative="two-sided", verbose=True):
+ """Gene set enrichment analysis by Fisher Exact Test.
+
+ gen... |
7818f9aa2d66ab0f4a99f731ecfb03e711e9ad6c | utils/send_messages.py | utils/send_messages.py | from django.conf import settings
import requests
def send_message_android(destination, title, message):
headers = {
'Authorization': 'key=' + settings.FIREBASE_SERVER_KEY,
'Content - Type': 'application/json'
}
payload = {
"to": destination,
"notification": {"title": title,... | """Push notification service
send_message_android and send_message_ios are the same, but this is intentional, in order
to support any future different conditions for both platforms, different keys or addtional parameters
shit happens sometimes ROFL!
"""
from django.conf import settings
from constance import config
i... | Add send_push_notification function and separate android and ios functions | Add send_push_notification function and separate android and ios functions
| Python | apache-2.0 | belatrix/BackendAllStars | ---
+++
@@ -1,8 +1,17 @@
+"""Push notification service
+
+send_message_android and send_message_ios are the same, but this is intentional, in order
+to support any future different conditions for both platforms, different keys or addtional parameters
+shit happens sometimes ROFL!
+
+"""
+
from django.conf import set... |
fc6b3df720ac05b715ae6478367f79e834c47c26 | pi_broadcast_service/rabbit.py | pi_broadcast_service/rabbit.py | import json
import pika
class Publisher(object):
def __init__(self, rabbit_url, exchange):
self._rabbit_url = rabbit_url
self._exchange = exchange
self._connection = pika.BlockingConnection(pika.URLParameters(self._rabbit_url))
self._channel = self._connection.channel()
def s... | import json
import pika
class Publisher(object):
def __init__(self, rabbit_url, exchange):
self._rabbit_url = rabbit_url
self._exchange = exchange
self._connection = pika.BlockingConnection(pika.URLParameters(self._rabbit_url))
self._channel = self._connection.channel()
se... | Make sure the exchange is there first | Make sure the exchange is there first
| Python | mit | projectweekend/Pi-Broadcast-Service | ---
+++
@@ -9,6 +9,7 @@
self._exchange = exchange
self._connection = pika.BlockingConnection(pika.URLParameters(self._rabbit_url))
self._channel = self._connection.channel()
+ self._channel.exchange_declare(exchange=self._exchange, type='direct')
def send(self, routing_key, me... |
02c74c5235b8ad821786213a3bcf5f824162454d | flax/linen/combinators.py | flax/linen/combinators.py | """Combinators of modules, such as a Sequential."""
from typing import Callable, Sequence
from flax.linen.module import Module
class Sequential(Module):
"""Applies a linear chain of Modules.
Meant to be used only for the simple case of fusing together callables where
the input of a particular module/op is the... | """Combinators of modules, such as a Sequential."""
from typing import Callable, Sequence
from flax.linen.module import Module
class Sequential(Module):
"""Applies a linear chain of Modules.
Meant to be used only for the simple case of fusing together callables where
the input of a particular module/op is the... | Include activations in Sequential example. | Include activations in Sequential example.
| Python | apache-2.0 | google/flax,google/flax | ---
+++
@@ -19,13 +19,14 @@
Example usage::
class Foo(nn.Module):
- feature_sizes: Sequence[int]
+ feature_sizes: Sequence[int]
- @nn.compact
- def __call__(self, x):
- return nn.Sequential([nn.Dense(layer_size, name=f'layers_{idx}')
- for idx,... |
0e6de6bc5890d6028a7115a62289bf26b0dd043b | hydra_agent/actions/server_conf.py | hydra_agent/actions/server_conf.py | # ==============================
# Copyright 2011 Whamcloud, Inc.
# ==============================
from hydra_agent.plugins import AgentPlugin
def set_server_conf(args = None):
import simplejson as json
data = json.loads(args.args)
from hydra_agent.store import AgentStore
AgentStore.set_server_conf(d... | # ==============================
# Copyright 2011 Whamcloud, Inc.
# ==============================
from hydra_agent.plugins import AgentPlugin
def _validate_conf(server_conf):
from hydra_agent.main_loop import MainLoop
result = MainLoop()._send_update(server_conf['url'], server_conf['token'], None, {})
if... | Test HTTP access to server before saving server config | Test HTTP access to server before saving server config
| Python | mit | intel-hpdd/intel-manager-for-lustre,intel-hpdd/intel-manager-for-lustre,intel-hpdd/intel-manager-for-lustre | ---
+++
@@ -4,12 +4,21 @@
from hydra_agent.plugins import AgentPlugin
+def _validate_conf(server_conf):
+ from hydra_agent.main_loop import MainLoop
+ result = MainLoop()._send_update(server_conf['url'], server_conf['token'], None, {})
+ if result == None:
+ from socket import getfqdn
+ ra... |
60edf2f1534e02a6da9aa715662a0e4ea8922191 | mk/get_config_dir.py | mk/get_config_dir.py | #!/usr/bin/env python
import os
component = os.getenv("COMPONENT")
if component == "ocaml":
print "/repos/xen-dist-ocaml.hg"
if component == "api-libs":
print "/repos/xen-api-libs-rpm-buildroot"
| #!/usr/bin/env python
import os
component = os.getenv("COMPONENT")
if component == "ocaml":
print "/repos/xen-dist-ocaml.hg"
if component == "api-libs":
print "/repos/xen-api-libs-specs"
| Change name of config repo for api-libs component | Change name of config repo for api-libs component
Signed-off-by: Jon Ludlam <e7e3380887a8f95cc9dc4f0d51dedc7e849a287a@eu.citrix.com>
| Python | lgpl-2.1 | simonjbeaumont/planex,jonludlam/planex,euanh/planex-cleanhistory,jonludlam/planex,djs55/planex,djs55/planex,djs55/planex,simonjbeaumont/planex,jonludlam/planex,euanh/planex-cleanhistory,euanh/planex-cleanhistory,simonjbeaumont/planex | ---
+++
@@ -7,5 +7,5 @@
if component == "ocaml":
print "/repos/xen-dist-ocaml.hg"
if component == "api-libs":
- print "/repos/xen-api-libs-rpm-buildroot"
+ print "/repos/xen-api-libs-specs"
|
0043fe9c8de4d8341afbcea388f472a50017de2c | jiradoc/__main__.py | jiradoc/__main__.py | # ------------------------------------------------------------
# __main__.py
#
# The main program which expects a jiradoc formatted file to
# be passed in as a cmdline option. It reads the file and
# parses its content to Story objects.
# ------------------------------------------------------------
import argparse
impo... | # ------------------------------------------------------------
# __main__.py
#
# The main program
# ------------------------------------------------------------
import argparse
import os
import pkg_resources
import sys
from jiradoc.parser.parser import parser as jiradoc_parser
def main(args=None):
parser = argpa... | Validate that the input file ends with .jiradoc | Validate that the input file ends with .jiradoc
| Python | mit | lucianovdveekens/jiradoc | ---
+++
@@ -1,27 +1,35 @@
# ------------------------------------------------------------
# __main__.py
#
-# The main program which expects a jiradoc formatted file to
-# be passed in as a cmdline option. It reads the file and
-# parses its content to Story objects.
+# The main program
# --------------------------... |
af2c9647e64ad0e0575b191e35e38f8bf23ed6f8 | config.py | config.py | ###
# Copyright (c) 2012-2013, spline
# All rights reserved.
#
#
###
import supybot.conf as conf
import supybot.registry as registry
from supybot.i18n import PluginInternationalization, internationalizeDocstring
_ = PluginInternationalization('NFL')
def configure(advanced):
# This will be called by supybot to co... | ###
# Copyright (c) 2012-2013, spline
# All rights reserved.
#
#
###
import supybot.conf as conf
import supybot.registry as registry
def configure(advanced):
# This will be called by supybot to configure this module. advanced is
# a bool that specifies whether the user identified himself as an advanced
#... | Remove internationalization because its not needed. | Remove internationalization because its not needed.
| Python | mit | cottongin/NFL,fasteddie2/NFL,reticulatingspline/NFL | ---
+++
@@ -7,9 +7,6 @@
import supybot.conf as conf
import supybot.registry as registry
-from supybot.i18n import PluginInternationalization, internationalizeDocstring
-
-_ = PluginInternationalization('NFL')
def configure(advanced):
# This will be called by supybot to configure this module. advanced is |
91c35078c7a8aad153d9aabe0b02fc3c48cfc76a | hesiod.py | hesiod.py | #!/usr/bin/env python
from _hesiod import bind, resolve
| #!/usr/bin/env python
"""
Present both functional and object-oriented interfaces for executing
lookups in Hesiod, Project Athena's service name resolution protocol.
"""
from _hesiod import bind, resolve
from pwd import struct_passwd
class HesiodParseError(Exception):
pass
class Lookup(object):
"""
A Ge... | Add object-oriented-style lookups for filsys, passwd, and uid lookups | Add object-oriented-style lookups for filsys, passwd, and uid lookups
The filsys entry parsing code is taken from pyHesiodFS and was explicitly
relicensed under the MIT license by Quentin Smith <quentin@mit.edu>
| Python | mit | ebroder/python-hesiod | ---
+++
@@ -1,3 +1,89 @@
#!/usr/bin/env python
+"""
+Present both functional and object-oriented interfaces for executing
+lookups in Hesiod, Project Athena's service name resolution protocol.
+"""
+
from _hesiod import bind, resolve
+
+from pwd import struct_passwd
+
+class HesiodParseError(Exception):
+ pass... |
637c19a54c6bee656ba3effd9316ad3d5587a963 | src/dynmen/__init__.py | src/dynmen/__init__.py | # -*- coding: utf-8 -*-
"""
dynmen - A simple python interface to dynamic menus like dmenu or rofi
import dynmen
menu = dynmen.Menu(['dmenu', '-fn', 'Sans-30'])
output = menu({'a': 1, 'b': 2, 'c': 3})
You can make the menu non-blocking by setting:
menu.process_mode = 'futures'
Please see the repository for more e... | # -*- coding: utf-8 -*-
"""
dynmen - A simple python interface to dynamic menus like dmenu or rofi
import dynmen
menu = dynmen.Menu(['dmenu', '-fn', 'Sans-30'])
output = menu({'a': 1, 'b': 2, 'c': 3})
You can make the menu non-blocking by setting:
menu.process_mode = 'futures'
Please see the repository for more e... | Add docstrings to dynmen.new_dmenu and dynmen.new_rofi | Add docstrings to dynmen.new_dmenu and dynmen.new_rofi
| Python | mit | frostidaho/dynmen | ---
+++
@@ -15,12 +15,20 @@
from .menu import Menu, MenuError, MenuResult
del menu
+def new_dmenu(**kwargs):
+ """Create an instance of dynmen.dmenu.DMenu(**kwargs)
-def new_dmenu(**kwargs):
+ The keyword arguments set the corresponding attribute
+ on the DMenu instance.
+ """
from .dmenu impor... |
968ef4bfb57743328587f9f693a7c531e20cbce0 | go_cli/tests/test_main.py | go_cli/tests/test_main.py | """ Tests for go_cli.main. """
from unittest import TestCase
from click.testing import CliRunner
from go_cli.main import cli
class TestCli(TestCase):
def test_help(self):
runner = CliRunner()
result = runner.invoke(cli, ['--help'])
self.assertEqual(result.exit_code, 0)
self.asse... | """ Tests for go_cli.main. """
from unittest import TestCase
from click.testing import CliRunner
from go_cli.main import cli
class TestCli(TestCase):
def test_help(self):
runner = CliRunner()
result = runner.invoke(cli, ['--help'])
self.assertEqual(result.exit_code, 0)
self.asse... | Check that export-contacts is included in the top-level command. | Check that export-contacts is included in the top-level command.
| Python | bsd-3-clause | praekelt/go-cli,praekelt/go-cli | ---
+++
@@ -13,8 +13,12 @@
result = runner.invoke(cli, ['--help'])
self.assertEqual(result.exit_code, 0)
self.assertTrue("Vumi Go command line utility." in result.output)
- self.assertTrue("send Send messages via an HTTP API (nostream)..."
- in result.output)
... |
c3b743b6dc757db4f2e063af8fa9ad6b228b3dcb | savate/buffer_event.py | savate/buffer_event.py | # -*- coding: utf-8 -*-
import errno
import collections
from savate import writev
# FIXME: should this be a method of BufferEvent below ?
# FIXME: handle Python2.x/Python3k compat here
def buffer_slice(buff, offset, size):
return buffer(buff, offset, size)
class BufferOutputHandler(object):
def __init__(sel... | # -*- coding: utf-8 -*-
import errno
import collections
from savate import writev
# FIXME: should this be a method of BufferEvent below ?
# FIXME: handle Python2.x/Python3k compat here
def buffer_slice(buff, offset, size):
return buffer(buff, offset, size)
class BufferOutputHandler(object):
def __init__(sel... | Use regular send() instead of our writev() | Use regular send() instead of our writev()
Buffering is apparently more rewarding performance-wise than using
zero-copy vectorised I/O ala writev(), hence there's no point to keep
using our homemade write() extension.
| Python | agpl-3.0 | noirbee/savate,noirbee/savate | ---
+++
@@ -27,15 +27,13 @@
total_sent_bytes = 0
try:
while self.buffer_queue:
- sent_bytes = writev.writev(self.sock.fileno(),
- self.buffer_queue)
+ sent_bytes = self.sock.send(self.buffer_queue[0])
... |
ea9273ba54dc502327bcca8b233e8d338aaa0d43 | pombola/south_africa/management/commands/south_africa_create_new_parties_for_election_2019.py | pombola/south_africa/management/commands/south_africa_create_new_parties_for_election_2019.py | import unicodecsv
from django.core.management.base import BaseCommand, CommandError
from pombola.core.models import Organisation, OrganisationKind
parties_csv = "pombola/south_africa/data/elections/2019/parties.csv"
class Command(BaseCommand):
help = "Creates new parties for the 2019 elections"
def handl... | import unicodecsv
from django.core.management.base import BaseCommand, CommandError
from pombola.core.models import Organisation, OrganisationKind
parties_csv = "pombola/south_africa/data/elections/2019/parties.csv"
class Command(BaseCommand):
help = "Creates new parties for the 2019 elections"
def handl... | Move party name to defaults argument | [ZA] Move party name to defaults argument
Some party names have changed, but the slug remains the same, so to
avoid errors move the name to the defaults sections so it's not checked
for existing parties.
| Python | agpl-3.0 | mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola,mysociety/pombola | ---
+++
@@ -19,7 +19,7 @@
party_name = row["name"]
party_kind = OrganisationKind.objects.get(slug="party")
party, created = Organisation.objects.get_or_create(
- slug=party_slug, name=party_name, kind=party_kind
+ slug=party_slug... |
d51fcb604f9e4a0f9b7d4178d4c85209594afbde | dataset/types.py | dataset/types.py | from datetime import datetime, date
from sqlalchemy import Integer, UnicodeText, Float, BigInteger
from sqlalchemy import Boolean, Date, DateTime, Unicode
from sqlalchemy.types import TypeEngine
class Types(object):
"""A holder class for easy access to SQLAlchemy type names."""
integer = Integer
string =... | from datetime import datetime, date
from sqlalchemy import Integer, UnicodeText, Float, BigInteger
from sqlalchemy import Boolean, Date, DateTime, Unicode
from sqlalchemy.types import TypeEngine
class Types(object):
"""A holder class for easy access to SQLAlchemy type names."""
integer = Integer
string =... | Replace `cls` argument with `self` Not sure if this was originally intended to be a `@classmethod` but it's now written and called as a method bound to an instance of the class. | Replace `cls` argument with `self`
Not sure if this was originally intended to be a `@classmethod` but it's now written and called as a method bound to an instance of the class.
| Python | mit | pudo/dataset | ---
+++
@@ -16,7 +16,7 @@
date = Date
datetime = DateTime
- def guess(cls, sample):
+ def guess(self, sample):
"""Given a single sample, guess the column type for the field.
If the sample is an instance of an SQLAlchemy type, the type will be
@@ -25,13 +25,13 @@
if isins... |
4e63db0d699eeb7a313708f82c129637222e1014 | src/penn_chime/utils.py | src/penn_chime/utils.py | """Utils."""
from base64 import b64encode
import pandas as pd
def dataframe_to_base64(df: pd.DataFrame) -> str:
"""Converts a dataframe to a base64-encoded CSV representation of that data.
This is useful for building datauris for use to download the data in the browser.
Arguments:
df: The data... | """Utils."""
from base64 import b64encode
import pandas as pd
def dataframe_to_base64(df: pd.DataFrame) -> str:
"""Converts a dataframe into csv base64-encoded data.
This is useful for building datauris for use to download the data in the browser.
Arguments:
df: The dataframe to convert
""... | Update excel_to_base64 to always close file handles | Update excel_to_base64 to always close file handles
| Python | mit | CodeForPhilly/chime,CodeForPhilly/chime,CodeForPhilly/chime | ---
+++
@@ -6,7 +6,7 @@
def dataframe_to_base64(df: pd.DataFrame) -> str:
- """Converts a dataframe to a base64-encoded CSV representation of that data.
+ """Converts a dataframe into csv base64-encoded data.
This is useful for building datauris for use to download the data in the browser.
@@ -18,... |
e14ca7e0a71e558ae9d8327248012d8109f9e0c5 | needlestack/base.py | needlestack/base.py | # -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
class SearchBackend(object):
pass
class Field(object):
"""
Base class for any field.
"""
name = None
def __init__(self, **kwargs)
self.options = kwargs
def set_name(self, name):
self.name... | # -*- coding: utf-8 -*-
from __future__ import unicode_literals, absolute_import
class SearchBackend(object):
pass
class Field(object):
"""
Base class for any field.
"""
name = None
def __init__(self, **kwargs)
for name, value in kwargs.items():
setattr(self, name, val... | Add type addaptation methods for generic field class. | Add type addaptation methods for generic field class.
| Python | bsd-3-clause | niwinz/needlestack | ---
+++
@@ -15,7 +15,24 @@
name = None
def __init__(self, **kwargs)
- self.options = kwargs
+ for name, value in kwargs.items():
+ setattr(self, name, value)
def set_name(self, name):
self.name = name
+
+ @classmethod
+ def from_python(cls, value):
+ "... |
b0961ac53a75ff3745d2297de80748f90c823827 | pajbot/migration/db.py | pajbot/migration/db.py | from contextlib import contextmanager
class DatabaseMigratable:
def __init__(self, conn):
self.conn = conn
@contextmanager
def create_resource(self):
with self.conn.cursor() as cursor:
# begins a transaction automatically
cursor.execute("CREATE TABLE IF NOT EXISTS... | from contextlib import contextmanager
class DatabaseMigratable:
def __init__(self, conn):
self.conn = conn
@contextmanager
def create_resource(self):
with self.conn.cursor() as cursor:
# begins a transaction automatically
cursor.execute("CREATE TABLE IF NOT EXISTS... | Change definition of schema_version table | Change definition of schema_version table
| Python | mit | pajlada/tyggbot,pajlada/tyggbot,pajlada/tyggbot,pajlada/tyggbot,pajlada/pajbot,pajlada/pajbot,pajlada/pajbot,pajlada/pajbot | ---
+++
@@ -10,7 +10,7 @@
with self.conn.cursor() as cursor:
# begins a transaction automatically
- cursor.execute("CREATE TABLE IF NOT EXISTS schema_version(revision_id INTEGER)")
+ cursor.execute("CREATE TABLE IF NOT EXISTS schema_version(revision_id INT NOT NULL)")
... |
6f6d1a7146020121a98ba6bb6cfa718686fc2a8d | ffflash/lib/api.py | ffflash/lib/api.py | from datetime import datetime
from pprint import pformat
from re import search as re_search
from re import sub as re_sub
class FFApi:
def __init__(self, content):
self.c = content
def pull(self, *fields):
c = self.c
for f in fields:
if isinstance(c,... | from datetime import datetime
from pprint import pformat
from re import search as re_search
from re import sub as re_sub
class FFApi:
def __init__(self, content):
self.c = content
def pull(self, *fields):
c = self.c
for f in fields:
if isinstance(c, dict) and f in c.keys()... | Fix double indentation error in FFApi class | Fix double indentation error in FFApi class
| Python | bsd-3-clause | spookey/ffflash,spookey/ffflash | ---
+++
@@ -5,31 +5,31 @@
class FFApi:
- def __init__(self, content):
- self.c = content
+ def __init__(self, content):
+ self.c = content
- def pull(self, *fields):
- c = self.c
- for f in fields:
- if isinstance(c, dict) and f in c.keys(... |
786d1ee8f58c95ab3d27d06bda2ec593cadef48e | apps/videos/tests/__init__.py | apps/videos/tests/__init__.py | from apps.videos.tests.celery_tasks import *
from apps.videos.tests.downloads import *
from apps.videos.tests.feeds import *
from apps.videos.tests.following import *
from apps.videos.tests.forms import *
from apps.videos.tests.metadata import *
from apps.videos.tests.models import *
from apps.videos.tests.rpc import *... | from apps.videos.tests.celery_tasks import *
from apps.videos.tests.downloads import *
from apps.videos.tests.feeds import *
from apps.videos.tests.following import *
from apps.videos.tests.forms import *
from apps.videos.tests.metadata import *
from apps.videos.tests.models import *
from apps.videos.tests.rpc import *... | Remove the syncing tests from the list. | Remove the syncing tests from the list.
| Python | agpl-3.0 | ReachingOut/unisubs,ofer43211/unisubs,ofer43211/unisubs,ReachingOut/unisubs,ujdhesa/unisubs,norayr/unisubs,wevoice/wesub,norayr/unisubs,eloquence/unisubs,wevoice/wesub,pculture/unisubs,ofer43211/unisubs,eloquence/unisubs,wevoice/wesub,norayr/unisubs,ujdhesa/unisubs,pculture/unisubs,eloquence/unisubs,ujdhesa/unisubs,wev... | ---
+++
@@ -6,7 +6,6 @@
from apps.videos.tests.metadata import *
from apps.videos.tests.models import *
from apps.videos.tests.rpc import *
-from apps.videos.tests.syncing import *
from apps.videos.tests.template_tags import *
from apps.videos.tests.uploads import *
from apps.videos.tests.video_types import * |
980aaa340a03353742d03be2844d4ceb829715c0 | numpy/core/__init__.py | numpy/core/__init__.py |
from info import __doc__
from numpy.version import version as __version__
import multiarray
import umath
import numerictypes as nt
multiarray.set_typeDict(nt.sctypeDict)
import _sort
from numeric import *
from fromnumeric import *
from defmatrix import *
import ma
import defchararray as char
import records as rec
fro... |
from info import __doc__
from numpy.version import version as __version__
import multiarray
import umath
import _internal # for freeze programs
import numerictypes as nt
multiarray.set_typeDict(nt.sctypeDict)
import _sort
from numeric import *
from fromnumeric import *
from defmatrix import *
import ma
import defchar... | Add an dummy import statement so that freeze programs pick up _internal.p | Add an dummy import statement so that freeze programs pick up _internal.p
git-svn-id: 77a43f9646713b91fea7788fad5dfbf67e151ece@3807 94b884b6-d6fd-0310-90d3-974f1d3f35e1
| Python | bsd-3-clause | teoliphant/numpy-refactor,chadnetzer/numpy-gaurdro,illume/numpy3k,teoliphant/numpy-refactor,illume/numpy3k,efiring/numpy-work,teoliphant/numpy-refactor,jasonmccampbell/numpy-refactor-sprint,Ademan/NumPy-GSoC,chadnetzer/numpy-gaurdro,efiring/numpy-work,teoliphant/numpy-refactor,Ademan/NumPy-GSoC,Ademan/NumPy-GSoC,jasonm... | ---
+++
@@ -4,6 +4,7 @@
import multiarray
import umath
+import _internal # for freeze programs
import numerictypes as nt
multiarray.set_typeDict(nt.sctypeDict)
import _sort |
4aa979273bfe698459d9a8066ee41741c3a68e3d | megamix/__init__.py | megamix/__init__.py | # Module of Gaussian Mixture models for python
__all__ = ['batch','online'] | # Module of Gaussian Mixture models for python
import megamix.batch
import megamix.online
__all__ = ['batch','online'] | Solve minor import problems with submodules | Solve minor import problems with submodules
| Python | apache-2.0 | 14thibea/megamix | ---
+++
@@ -1,3 +1,5 @@
# Module of Gaussian Mixture models for python
+import megamix.batch
+import megamix.online
__all__ = ['batch','online'] |
525441540306cb2ac385b0f633681e24587117dc | gdx2py/__init__.py | gdx2py/__init__.py | # -*- coding: utf-8 -*-
"""
Created on Wed Feb 24 11:01:10 2016
@author: ererkka
"""
__version__ = '1.2.2'
| # -*- coding: utf-8 -*-
"""
Created on Wed Feb 24 11:01:10 2016
@author: ererkka
"""
__version__ = '1.2.2'
from .gdxfile import GdxFile | Revert "Fixed bug with imports" | Revert "Fixed bug with imports"
This reverts commit 7b63b268a002a0ceb0b7bb2c6c57237bf6d5f25b.
| Python | mit | ererkka/GDX2py | ---
+++
@@ -6,3 +6,5 @@
"""
__version__ = '1.2.2'
+
+from .gdxfile import GdxFile |
b63ee83574605e79075ee834d2418cd58b722bc6 | docs/tests.py | docs/tests.py | from django.test import Client, TestCase
from django.core.urlresolvers import reverse
import views
class DocsTestCase(TestCase):
def setUp(self):
self.client = Client()
def test_index(self):
response = self.client.get(reverse(views.index))
self.assertEqual(response.status_code, 200)
... | from django.test import Client, TestCase
from django.core.urlresolvers import reverse
import views
class DocsTestCase(TestCase):
def setUp(self):
self.client = Client()
def test_index(self):
response = self.client.get(reverse(views.index))
self.assertEqual(response.status_code, 200)
... | Add test case for resources docs page | Add test case for resources docs page
| Python | mit | crcollins/chemtools-webapp,crcollins/chemtools-webapp,crcollins/chemtools-webapp,crcollins/chemtools-webapp,crcollins/chemtools-webapp | ---
+++
@@ -23,3 +23,7 @@
def test_technical(self):
response = self.client.get(reverse(views.technical))
self.assertEqual(response.status_code, 200)
+
+ def test_resources(self):
+ response = self.client.get(reverse(views.resources))
+ self.assertEqual(response.status_code, 200... |
56f7646413de01cb45825b30586231cf3ecbd43c | tests/test_flask_get.py | tests/test_flask_get.py | import unittest
from flask import Flask
from flask.ext.autodoc import Autodoc
class TestAutodocWithFlask(unittest.TestCase):
def setUp(self):
self.app = Flask(__name__)
self.autodoc = Autodoc(self.app)
@self.app.route('/')
@self.autodoc.doc()
def index():
"""R... | import json
import unittest
from flask import Flask
from flask.ext.autodoc import Autodoc
class TestAutodocWithFlask(unittest.TestCase):
def setUp(self):
self.app = Flask(__name__)
self.autodoc = Autodoc(self.app)
@self.app.route('/')
@self.autodoc.doc()
def index():
... | Make this test a bit harder. | Make this test a bit harder.
| Python | mit | jwg4/flask-autodoc,jwg4/flask-autodoc | ---
+++
@@ -1,3 +1,4 @@
+import json
import unittest
from flask import Flask
@@ -32,3 +33,6 @@
response = self.client.get('/docs')
self.assertEqual(response.status_code, 200)
+
+ data = json.loads(response.data)
+ self.assertIn('endpoints', data) |
1ac385de638854cad1095a3f81a63ecf45fa60ae | organizer/models.py | organizer/models.py | from django.db import models
# Model Field Reference
# https://docs.djangoproject.com/en/1.8/ref/models/fields/
class Tag(models.Model):
name = models.CharField(
max_length=31, unique=True)
slug = models.SlugField(
max_length=31,
unique=True,
help_text='A label for URL config... | from django.db import models
# Model Field Reference
# https://docs.djangoproject.com/en/1.8/ref/models/fields/
class Tag(models.Model):
name = models.CharField(
max_length=31, unique=True)
slug = models.SlugField(
max_length=31,
unique=True,
help_text='A label for URL config... | Declare Meta class in NewsLink model. | Ch03: Declare Meta class in NewsLink model. [skip ci]
| Python | bsd-2-clause | jambonrose/DjangoUnleashed-1.8,jambonrose/DjangoUnleashed-1.8 | ---
+++
@@ -48,6 +48,11 @@
link = models.URLField(max_length=255)
startup = models.ForeignKey(Startup)
+ class Meta:
+ verbose_name = 'news article'
+ ordering = ['-pub_date']
+ get_latest_by = 'pub_date'
+
def __str__(self):
return "{}: {}".format(
self.... |
bf09097e66c02764d81516a4161ca607ccbd0bb5 | lfs/other_translations.py | lfs/other_translations.py | def _():
return 1
_(u'Price excludes tax')
_(u'Price includes tax')
_(u'Street')
_(u'Left')
_(u'Right')
_(u'Average Rating')
_(u'Zip Code')
_(u'Last Order Number')
_(u'Format')
_(u"Cart Price")
_(u"Combined Length and Girth")
| def _():
return 1
_(u'Price excludes tax')
_(u'Price includes tax')
_(u'Street / No')
_(u'Left')
_(u'Right')
_(u'Average Rating')
_(u'Zip Code')
_(u'Last Order Number')
_(u'Format')
_(u"Cart Price")
_(u"Combined Length and Girth")
| Add house number to street label within address form | Add house number to street label within address form
| Python | bsd-3-clause | diefenbach/django-lfs,diefenbach/django-lfs,diefenbach/django-lfs | ---
+++
@@ -4,7 +4,7 @@
_(u'Price excludes tax')
_(u'Price includes tax')
-_(u'Street')
+_(u'Street / No')
_(u'Left')
_(u'Right')
_(u'Average Rating') |
f317f946f9f17cbaf162b12c8770908abba5bbeb | linter.py | linter.py | #
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by NotSqrt
# Copyright (c) 2013 NotSqrt
#
# License: MIT
#
"""This module exports the Cppcheck plugin class."""
from SublimeLinter.lint import Linter, util
class Cppcheck(Linter):
"""Provides an interface to cpp... | #
# linter.py
# Linter for SublimeLinter3, a code checking framework for Sublime Text 3
#
# Written by NotSqrt
# Copyright (c) 2013 NotSqrt
#
# License: MIT
#
"""This module exports the Cppcheck plugin class."""
from SublimeLinter.lint import Linter, util
class Cppcheck(Linter):
"""Provides an interface to cpp... | Change on the regex variable such that it distinguish warnings from errors. | Change on the regex variable such that it distinguish warnings from errors.
| Python | mit | SublimeLinter/SublimeLinter-cppcheck,ftoulemon/SublimeLinter-cppcheck | ---
+++
@@ -19,7 +19,7 @@
syntax = 'c++'
cmd = ('cppcheck', '--template=gcc', '--inline-suppr', '--quiet', '*', '@')
- regex = r'^.+:(?P<line>\d+):\s+(?P<message>.+)'
+ regex = r'^.+:(?P<line>\d+):\s+((?P<error>error)|(?P<warning>warning|style|performance|portability|information)):\s+(?P<message>.+)... |
f8c440d849a794298f119735ebe10290fc66f2ec | mopidy/__main__.py | mopidy/__main__.py | import asyncore
import logging
import multiprocessing
import os
import sys
sys.path.insert(0,
os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
from mopidy import settings, SettingsError
from mopidy.process import CoreProcess
from mopidy.utils import get_class
logger = logging.getLogger('mopidy.ma... | import asyncore
import logging
import multiprocessing
import optparse
import os
import sys
sys.path.insert(0,
os.path.abspath(os.path.join(os.path.dirname(__file__), '../')))
from mopidy import settings, SettingsError
from mopidy.process import CoreProcess
from mopidy.utils import get_class
logger = logging.getL... | Add -v and -q options for more or less output | Add -v and -q options for more or less output
| Python | apache-2.0 | jodal/mopidy,tkem/mopidy,jodal/mopidy,swak/mopidy,pacificIT/mopidy,tkem/mopidy,adamcik/mopidy,jcass77/mopidy,jmarsik/mopidy,adamcik/mopidy,ali/mopidy,jmarsik/mopidy,pacificIT/mopidy,swak/mopidy,jmarsik/mopidy,hkariti/mopidy,quartz55/mopidy,rawdlite/mopidy,mokieyue/mopidy,ZenithDK/mopidy,bencevans/mopidy,SuperStarPL/mop... | ---
+++
@@ -1,6 +1,7 @@
import asyncore
import logging
import multiprocessing
+import optparse
import os
import sys
@@ -14,12 +15,23 @@
logger = logging.getLogger('mopidy.main')
def main():
- _setup_logging(2)
+ options, args = _parse_options()
+ _setup_logging(options.verbosity_level)
core_q... |
a521c4a4a55437452a4a7d006ec8faea0521ea05 | capstone/rl/learners/sarsa.py | capstone/rl/learners/sarsa.py | from ..learner import Learner
from ..policies import RandomPolicy
from ..value_functions import TabularQ
from ...utils import check_random_state
class Sarsa(Learner):
def __init__(self, env, policy=None, learning_rate=0.1, discount_factor=0.99,
n_episodes=1000, verbose=True, random_state=None):
... | from ..learner import Learner
from ..policies import RandomPolicy
from ..value_functions import TabularQ
from ...utils import check_random_state
class Sarsa(Learner):
def __init__(self, env, policy=None, learning_rate=0.1, discount_factor=0.99,
n_episodes=1000, verbose=True, random_state=None):
... | Create tabular q-function with kwarg random_state | Create tabular q-function with kwarg random_state
| Python | mit | davidrobles/mlnd-capstone-code | ---
+++
@@ -13,8 +13,8 @@
self.learning_rate = learning_rate
self.discount_factor = discount_factor
self.random_state = check_random_state(random_state)
- self.policy = policy or RandomPolicy(env.actions, self.random_state)
- self.qf = TabularQ(self.random_state)
+ self... |
b388722fcc70d2787b91b5a4492cb9659cea7a42 | parsl/providers/torque/template.py | parsl/providers/torque/template.py | template_string = '''#!/bin/bash
#PBS -S /bin/bash
#PBS -N ${jobname}
#PBS -m n
#PBS -k eo
#PBS -l walltime=$walltime
#PBS -l nodes=${nodes_per_block}:ppn=${tasks_per_node}
#PBS -o ${submit_script_dir}/${jobname}.submit.stdout
#PBS -e ${submit_script_dir}/${jobname}.submit.stderr
${scheduler_options}
${worker_init}
... | template_string = '''#!/bin/bash
#PBS -S /bin/bash
#PBS -N ${jobname}
#PBS -m n
#PBS -l walltime=$walltime
#PBS -l nodes=${nodes_per_block}:ppn=${tasks_per_node}
#PBS -o ${submit_script_dir}/${jobname}.submit.stdout
#PBS -e ${submit_script_dir}/${jobname}.submit.stderr
${scheduler_options}
${worker_init}
export JOBN... | Remove line which was preventing stdout redirect | Remove line which was preventing stdout redirect
I think this line tries to send stdout and stderr to the same file. I'm
not really sure why removing it causes the later specification of the
stdout and stderr lines to be respected, but we don't want them in the
same file in any case. Fixes #647.
| Python | apache-2.0 | Parsl/parsl,Parsl/parsl,Parsl/parsl,swift-lang/swift-e-lab,swift-lang/swift-e-lab,Parsl/parsl | ---
+++
@@ -3,7 +3,6 @@
#PBS -S /bin/bash
#PBS -N ${jobname}
#PBS -m n
-#PBS -k eo
#PBS -l walltime=$walltime
#PBS -l nodes=${nodes_per_block}:ppn=${tasks_per_node}
#PBS -o ${submit_script_dir}/${jobname}.submit.stdout |
3b83e983f1e7cd3a0866109c66dd91903db87fa1 | goodtablesio/integrations/github/tasks/repos.py | goodtablesio/integrations/github/tasks/repos.py | import datetime
from goodtablesio.models.user import User
from goodtablesio.models.source import Source
from goodtablesio.services import database
from goodtablesio.celery_app import celery_app
from goodtablesio.integrations.github.utils.repos import iter_repos_by_token
@celery_app.task(name='goodtablesio.github.sync... | import datetime
from goodtablesio.models.user import User
from goodtablesio.services import database
from goodtablesio.celery_app import celery_app
from goodtablesio.integrations.github.models.repo import GithubRepo
from goodtablesio.integrations.github.utils.repos import iter_repos_by_token
@celery_app.task(name='go... | Use own model class on github task | Use own model class on github task
| Python | agpl-3.0 | frictionlessdata/goodtables.io,frictionlessdata/goodtables.io,frictionlessdata/goodtables.io,frictionlessdata/goodtables.io | ---
+++
@@ -1,8 +1,8 @@
import datetime
from goodtablesio.models.user import User
-from goodtablesio.models.source import Source
from goodtablesio.services import database
from goodtablesio.celery_app import celery_app
+from goodtablesio.integrations.github.models.repo import GithubRepo
from goodtablesio.integra... |
274a1b43a57f838f078d11ef71803d46f8fd34bf | perfect-numbers/perfect_numbers.py | perfect-numbers/perfect_numbers.py | def divisor_generator(n):
big_factors = {1}
for i in range(2, n):
if i in big_factors:
break
if n % i == 0:
big_factors.add(n // i)
yield i
yield from big_factors
def is_perfect(n):
return n == sum(divisor_generator(n))
| from math import sqrt, ceil
def divisor_generator(n):
yield 1
for i in range(2, ceil(sqrt(n))):
if n % i == 0:
yield i
yield n // i
def is_perfect(n):
return n == sum(divisor_generator(n))
| Refactor to give faster solution | Refactor to give faster solution
| Python | agpl-3.0 | CubicComet/exercism-python-solutions | ---
+++
@@ -1,12 +1,12 @@
+from math import sqrt, ceil
+
+
def divisor_generator(n):
- big_factors = {1}
- for i in range(2, n):
- if i in big_factors:
- break
+ yield 1
+ for i in range(2, ceil(sqrt(n))):
if n % i == 0:
- big_factors.add(n // i)
yield i... |
9fe93f19c38ea1e41ce7bfe5aca8ec9327b195b5 | test/test_reqmodules.py | test/test_reqmodules.py |
import tserver, sys, md5, math
from disco import Disco, result_iterator
def data_gen(path):
return path[1:] + "\n"
def fun_map(e, params):
k = str(int(math.ceil(float(e))) ** 2)
return [(md5.new(k).hexdigest(), "")]
tserver.run_server(data_gen)
disco = Disco(sys.argv[1])
inputs = [1, 485, 3... |
import tserver, sys, base64, math
from disco import Disco, result_iterator
def data_gen(path):
return path[1:] + "\n"
def fun_map(e, params):
k = str(int(math.ceil(float(e))) ** 2)
return [(base64.encodestring(k), "")]
tserver.run_server(data_gen)
disco = Disco(sys.argv[1])
inputs = [1, 485... | Use the base64 module for testing rather than md5 which is deprecated in python2.6 | Use the base64 module for testing rather than md5 which is deprecated in python2.6
| Python | bsd-3-clause | ErikDubbelboer/disco,beni55/disco,ErikDubbelboer/disco,beni55/disco,pombredanne/disco,scrapinghub/disco,scrapinghub/disco,pombredanne/disco,ErikDubbelboer/disco,seabirdzh/disco,pooya/disco,ErikDubbelboer/disco,discoproject/disco,pombredanne/disco,mwilliams3/disco,simudream/disco,discoproject/disco,mwilliams3/disco,ktkt... | ---
+++
@@ -1,5 +1,5 @@
-import tserver, sys, md5, math
+import tserver, sys, base64, math
from disco import Disco, result_iterator
def data_gen(path):
@@ -7,7 +7,7 @@
def fun_map(e, params):
k = str(int(math.ceil(float(e))) ** 2)
- return [(md5.new(k).hexdigest(), "")]
+ return [(base... |
49a2502043e1d7ad5f3907779be7815a39ad85c7 | awx/main/models/activity_stream.py | awx/main/models/activity_stream.py | # Copyright (c) 2013 AnsibleWorks, Inc.
# All Rights Reserved.
from django.db import models
class ActivityStream(models.Model):
'''
Model used to describe activity stream (audit) events
'''
OPERATION_CHOICES = [
('create', _('Entity Created')),
('update', _("Entity Updated")),
... | # Copyright (c) 2013 AnsibleWorks, Inc.
# All Rights Reserved.
from django.db import models
from django.utils.translation import ugettext_lazy as _
class ActivityStream(models.Model):
'''
Model used to describe activity stream (audit) events
'''
class Meta:
app_label = 'main'
OPERATION_... | Fix up some issues with supporting schema migration | Fix up some issues with supporting schema migration
| Python | apache-2.0 | wwitzel3/awx,wwitzel3/awx,snahelou/awx,snahelou/awx,snahelou/awx,wwitzel3/awx,wwitzel3/awx,snahelou/awx | ---
+++
@@ -3,11 +3,16 @@
from django.db import models
+from django.utils.translation import ugettext_lazy as _
class ActivityStream(models.Model):
'''
Model used to describe activity stream (audit) events
'''
+
+ class Meta:
+ app_label = 'main'
+
OPERATION_CHOICES = [
... |
5fe73f508d87018db1d6f574cd22d76b46cbe862 | events/api.py | events/api.py | '''
Api for the events app
'''
import datetime
from models import Event
from tastypie.utils import trailing_slash
from apis.resources.base import BaseResource
from django.conf.urls.defaults import url
class EventResource(BaseResource):
class Meta:
queryset = Event.objects.all()
allowed_methods = ['... | '''
Api for the events app
'''
import datetime
from models import Event
from tastypie.utils import trailing_slash
from apis.resources.base import BaseResource
from django.conf.urls.defaults import url
class EventResource(BaseResource):
class Meta:
queryset = Event.objects.all()
allowed_methods = ['... | Fix the event APIv2 to account for retrieval of a single event. | Fix the event APIv2 to account for retrieval of a single event.
| Python | bsd-3-clause | alonisser/Open-Knesset,OriHoch/Open-Knesset,habeanf/Open-Knesset,daonb/Open-Knesset,otadmor/Open-Knesset,navotsil/Open-Knesset,MeirKriheli/Open-Knesset,DanaOshri/Open-Knesset,Shrulik/Open-Knesset,daonb/Open-Knesset,otadmor/Open-Knesset,habeanf/Open-Knesset,DanaOshri/Open-Knesset,Shrulik/Open-Knesset,daonb/Open-Knesset,... | ---
+++
@@ -14,12 +14,20 @@
def override_urls(self):
return [
- url(r'^(?P<resource_name>%s)/?' % self._meta.resource_name,
+ url(r'^(?P<resource_name>%s)/?$' % self._meta.resource_name,
self.wrap_view('get_future_events'),
- name = 'api-get-future... |
2d7c7872bb030a280de6047a609d14560ff7e29f | fabfile/eg.py | fabfile/eg.py | from fabric.api import task, local, run, lcd, cd, env
from os.path import exists as file_exists
from fabtools.python import virtualenv
from os import path
PWD = path.join(path.dirname(__file__), '..')
VENV_DIR = path.join(PWD, '.env')
@task
def mnist():
with virtualenv(VENV_DIR):
with lcd(PWD):
... | from fabric.api import task, local, run, lcd, cd, env
from os.path import exists as file_exists
from fabtools.python import virtualenv
from os import path
PWD = path.join(path.dirname(__file__), '..')
VENV_DIR = path.join(PWD, '.env')
@task
def mnist():
with virtualenv(VENV_DIR):
with lcd(PWD):
... | Patch mnist example to specify theano for keras. | Patch mnist example to specify theano for keras.
| Python | mit | spacy-io/thinc,spacy-io/thinc,explosion/thinc,explosion/thinc,explosion/thinc,explosion/thinc,spacy-io/thinc | ---
+++
@@ -15,4 +15,14 @@
local('pip install -e .')
local('pip install keras')
print("Using Keras to get MNIST data")
- local('python examples/mnist.py')
+ local('KERAS_BACKEND="theano" python examples/mnist.py')
+
+
+@task
+def basic_tagger():
+ with v... |
81cd919f4f85f2d26d89006234d608aebe8a8047 | plugins/clue/clue.py | plugins/clue/clue.py | from __future__ import unicode_literals
# don't convert to ascii in py2.7 when creating string to return
crontable = []
outputs = []
state = {}
def process_message(data):
channel = data['channel']
if channel not in state.keys():
state[channel] = {'count': 0, 'clue': ''}
st = state[channel]
... | from __future__ import unicode_literals
# don't convert to ascii in py2.7 when creating string to return
crontable = []
outputs = []
state = {}
class ClueState:
def __init__(self):
self.count = 0
self.clue = ''
def process_message(data):
channel = data['channel']
if channel not in sta... | Switch to a ClueState class instead of just a dictionary | Switch to a ClueState class instead of just a dictionary
This makes the syntax a little easier to read, (such as "st.count"
instead of "st['count']").
| Python | mit | cworth-gh/stony | ---
+++
@@ -7,21 +7,27 @@
state = {}
+class ClueState:
+
+ def __init__(self):
+ self.count = 0
+ self.clue = ''
+
def process_message(data):
channel = data['channel']
if channel not in state.keys():
- state[channel] = {'count': 0, 'clue': ''}
+ state[channel] = ClueSt... |
1f3e42047a67001719220a5a42fe0c5f51d2b740 | Demo/sockets/echosvr.py | Demo/sockets/echosvr.py | #! /usr/local/bin/python
# Python implementation of an 'echo' tcp server: echo all data it receives.
#
# This is the simplest possible server, sevicing a single request only.
import sys
from socket import *
# The standard echo port isn't very useful, it requires root permissions!
# ECHO_PORT = 7
ECHO_PORT = 50000 + ... | #! /usr/local/bin/python
# Python implementation of an 'echo' tcp server: echo all data it receives.
#
# This is the simplest possible server, sevicing a single request only.
import sys
from socket import *
# The standard echo port isn't very useful, it requires root permissions!
# ECHO_PORT = 7
ECHO_PORT = 50000 + ... | Change listen(0) to listen(1) for Solaris 2 sockets | Change listen(0) to listen(1) for Solaris 2 sockets
| Python | mit | sk-/python2.7-type-annotator,sk-/python2.7-type-annotator,sk-/python2.7-type-annotator | ---
+++
@@ -19,7 +19,7 @@
port = ECHO_PORT
s = socket(AF_INET, SOCK_STREAM)
s.bind('', port)
- s.listen(0)
+ s.listen(1)
conn, (remotehost, remoteport) = s.accept()
print 'connected by', remotehost, remoteport
while 1: |
2f968509be6ae8e3bcd15d0f46ebc3ba290ca086 | astroplan/exceptions.py | astroplan/exceptions.py | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from astropy.utils.exceptions import AstropyWarning
__all__ = ["TargetAlwaysUpWarning", "TargetNeverUpWarning",
"OldEarthOrientationDa... | # Licensed under a 3-clause BSD style license - see LICENSE.rst
from __future__ import (absolute_import, division, print_function,
unicode_literals)
from astropy.utils.exceptions import AstropyWarning
__all__ = ["TargetAlwaysUpWarning", "TargetNeverUpWarning",
"OldEarthOrientationDa... | Make all astroplan warnings decend from an AstroplanWarning | Make all astroplan warnings decend from an AstroplanWarning
| Python | bsd-3-clause | StuartLittlefair/astroplan | ---
+++
@@ -8,19 +8,22 @@
"OldEarthOrientationDataWarning", "PlotWarning",
"PlotBelowHorizonWarning"]
-class TargetAlwaysUpWarning(AstropyWarning):
+class AstroplanWarning(AstropyWarning):
+ """Superclass for warnings used by astroplan"""
+
+class TargetAlwaysUpWarning(AstroplanWarning):
... |
5b00b6cd392a1f5f317cc18893198bb5d62c565d | pystache/parsed.py | pystache/parsed.py | # coding: utf-8
"""
Exposes a class that represents a parsed (or compiled) template.
"""
class ParsedTemplate(object):
"""
Represents a parsed or compiled template.
An instance wraps a list of unicode strings and node objects. A node
object must have a `render(engine, stack)` method that accepts ... | # coding: utf-8
"""
Exposes a class that represents a parsed (or compiled) template.
"""
class ParsedTemplate(object):
"""
Represents a parsed or compiled template.
An instance wraps a list of unicode strings and node objects. A node
object must have a `render(engine, stack)` method that accepts ... | Rename variable name from "val" to "node". | Rename variable name from "val" to "node".
| Python | mit | charbeljc/pystache,nitish116/pystache,defunkt/pystache,harsh00008/pystache,rismalrv/pystache,nitish116/pystache,arlenesr28/pystache,nitish116/pystache,rismalrv/pystache,charbeljc/pystache,arlenesr28/pystache,harsh00008/pystache,beni55/pystache,harsh00008/pystache,jrnold/pystache,rismalrv/pystache,jrnold/pystache,arlene... | ---
+++
@@ -40,10 +40,10 @@
"""
# We avoid use of the ternary operator for Python 2.4 support.
- def get_unicode(val):
- if type(val) is unicode:
- return val
- return val.render(engine, context)
+ def get_unicode(node):
+ if type(node)... |
336edeebe5ac04df719569efa40e2fef01a2dccc | testproject/__init__.py | testproject/__init__.py | #!/usr/bin/env python
import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.testproject.settings")
from django.test.utils import get_runner
from django.conf import settings
def runtests():
# Stolen from django/core/management/commands/test.py
TestRunner = get_runner(settings)
t... | #!/usr/bin/env python
import os
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.testproject.settings")
import django
from django.test.utils import get_runner
from django.conf import settings
def runtests():
if hasattr(django, 'setup'):
# django >= 1.7
django.setup()
# S... | Set up the app registry when running tests on django 1.7 | Set up the app registry when running tests on django 1.7
(cherry picked from commit 7b3c994758254f16e8f47bf0f13b363d98082f20)
Signed-off-by: Antoine Catton <4589f2e060cef08c47d868a06754605a848a1006@fusionbox.com>
| Python | bsd-2-clause | fusionbox/django-argonauts | ---
+++
@@ -3,10 +3,14 @@
import sys
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "testproject.testproject.settings")
+import django
from django.test.utils import get_runner
from django.conf import settings
def runtests():
+ if hasattr(django, 'setup'):
+ # django >= 1.7
+ django.setup()
... |
80958236edd4390b3f2f9fe4848de68fdda60513 | hurdles/tools.py | hurdles/tools.py | from functools import wraps
def extra_setup(setup_code):
"""Allows to setup some extra context to it's decorated function.
As a convention, the bench decorated function should always handle
*args and **kwargs. Kwargs will be updated with the extra context
set by the decorator.
Example:
@... | from functools import wraps
def extra_setup(setup_code):
"""Allows to setup some extra context to it's decorated function.
As a convention, the bench decorated function should always handle
*args and **kwargs. Kwargs will be updated with the extra context
set by the decorator.
Example:
@... | Update : extra_setup compiles code, and runs it into custom global context | Update : extra_setup compiles code, and runs it into custom global context
| Python | mit | oleiade/Hurdles | ---
+++
@@ -17,7 +17,8 @@
# Exec extra setup code and put it in a local
# context passed to function through kwargs.
context = {}
- exec setup_code in {}, context
+ compiled_code = compile(setup_code, '<string>', 'exec')
+ exec compiled_code in context
@wraps... |
918c30a22bf6dc6e0c69037ba21759710c5e7602 | glance_registry_local_check.py | glance_registry_local_check.py | #!/usr/bin/env python
from maas_common import (status_ok, status_err, metric, metric_bool,
get_auth_ref)
from requests import Session
from requests import exceptions as exc
def check(auth_ref):
registry_endpoint = 'http://127.0.0.1:9191'
api_status = 1
milliseconds = 0
s = Se... | #!/usr/bin/env python
from maas_common import (status_ok, status_err, metric, get_keystone_client,
get_auth_ref)
from requests import Session
from requests import exceptions as exc
def check(auth_ref):
keystone = get_keystone_client(auth_ref)
tenant_id = keystone.tenant_id
auth_t... | Revert "Use new metric_bool function" | Revert "Use new metric_bool function"
This reverts commit e186b59c83f187900ce4bfd8b02b735d068434bb.
| Python | apache-2.0 | sigmavirus24/rpc-openstack,stevelle/rpc-openstack,cfarquhar/rpc-maas,jacobwagner/rpc-openstack,andymcc/rpc-openstack,cfarquhar/rpc-maas,briancurtin/rpc-maas,darrenchan/rpc-openstack,cfarquhar/rpc-openstack,stevelle/rpc-openstack,claco/rpc-openstack,major/rpc-openstack,sigmavirus24/rpc-openstack,miguelgrinberg/rpc-opens... | ---
+++
@@ -1,20 +1,25 @@
#!/usr/bin/env python
-from maas_common import (status_ok, status_err, metric, metric_bool,
+from maas_common import (status_ok, status_err, metric, get_keystone_client,
get_auth_ref)
from requests import Session
from requests import exceptions as exc
def ... |
3ec825c5ad8f1b4bacbbe9921d7caa46ad5ccd55 | comrade/core/context_processors.py | comrade/core/context_processors.py | from django.conf import settings
from django.contrib.sites.models import Site
from settings import DeploymentType
def default(request):
context = {}
context['DEPLOYMENT'] = settings.DEPLOYMENT
context['site'] = Site.objects.get_current()
if settings.DEPLOYMENT != DeploymentType.PRODUCTION:
cont... | from django.conf import settings
from django.contrib.sites.models import Site
from settings import DeploymentType
def default(request):
context = {}
context['DEPLOYMENT'] = settings.DEPLOYMENT
context['site'] = Site.objects.get_current()
if settings.DEPLOYMENT != DeploymentType.PRODUCTION:
cont... | Add contact email to context. | Add contact email to context.
| Python | mit | bueda/django-comrade | ---
+++
@@ -8,6 +8,7 @@
context['site'] = Site.objects.get_current()
if settings.DEPLOYMENT != DeploymentType.PRODUCTION:
context['GIT_COMMIT'] = settings.GIT_COMMIT
+ context['site_email'] = settings.CONTACT_EMAIL
return context
def ssl_media(request): |
cfbe762a0e752dcb58edbbd0835371ecc300d3f4 | nosewatch/plugin.py | nosewatch/plugin.py | import sys
from nose.plugins import Plugin
from subprocess import Popen
class WatchPlugin(Plugin):
"""
Plugin that use watchdog for continuous tests run.
"""
name = 'watch'
is_watching = False
sys = sys
def call(self, args):
Popen(args).wait()
def finalize(self, result):
... | import sys
from nose.plugins import Plugin
from subprocess import Popen
class WatchPlugin(Plugin):
"""
Plugin that use watchdog for continuous tests run.
"""
name = 'watch'
is_watching = False
sys = sys
def call(self, args):
Popen(args).wait()
def finalize(self, result):
... | Add try block to argv remove statement | Add try block to argv remove statement
When running nose-watch withing an environment like django-nose argv doesn't contain any arguments to remove.
| Python | bsd-2-clause | lukaszb/nose-watch,lukaszb/nose-watch | ---
+++
@@ -16,7 +16,10 @@
def finalize(self, result):
argv = list(self.sys.argv)
- argv.remove('--with-watch')
+ try:
+ argv.remove('--with-watch')
+ except ValueError:
+ pass
watchcmd = 'clear && ' + ' '.join(argv)
call_args = ['watchmedo'... |
cf99ee9a106b862ee3401399224e4730d758eacc | rated/middleware.py | rated/middleware.py |
from . import settings
from django.http import HttpResponse
import time
import redis
# Connection pool
POOL = redis.ConnectionPool(**settings.REDIS)
class RatedMiddleware(object):
def process_view(self, request, view_func, view_args, view_kwargs):
# Try to determine the realm for this view
try... |
from . import settings
from django.http import HttpResponse
import time
import redis
# Connection pool
POOL = redis.ConnectionPool(**settings.REDIS)
class RatedMiddleware(object):
def process_view(self, request, view_func, view_args, view_kwargs):
# Try to determine the realm for this view
try... | Use more appropriate status code | Use more appropriate status code
| Python | bsd-3-clause | funkybob/django-rated | ---
+++
@@ -46,5 +46,5 @@
pipe.zcard(key)
size = pipe.execute()[-1]
if size > conf.get('limit', settings.DEFAULT_LIMIT):
- return HttpResponse(status=501)
+ return HttpResponse(status=429)
return None |
c3762443859ada75687e5a62d576fe8140a42a7c | tests/test_csv2iati.py | tests/test_csv2iati.py | import pytest
from web_test_base import *
class TestCSV2IATI(WebTestBase):
requests_to_load = {
'CSV2IATI Homepage': {
'url': 'http://csv2iati.iatistandard.org/'
}
}
def test_contains_links(self, loaded_request):
"""
Test that each page contains links to the def... | import pytest
from web_test_base import *
class TestCSV2IATI(WebTestBase):
requests_to_load = {
'CSV2IATI Homepage': {
'url': 'http://csv2iati.iatistandard.org/'
}
}
| Remove redundant csv2iati test now site has been decommissioned | Remove redundant csv2iati test now site has been decommissioned
| Python | mit | IATI/IATI-Website-Tests | ---
+++
@@ -7,29 +7,3 @@
'url': 'http://csv2iati.iatistandard.org/'
}
}
-
- def test_contains_links(self, loaded_request):
- """
- Test that each page contains links to the defined URLs.
- """
- result = utility.get_links_from_page(loaded_request)
-
- a... |
6c3b5a314c9ba25fba2b0a605215d2fdad97e8dc | tests/test_evaluate.py | tests/test_evaluate.py | import numpy as np
from numpy.testing import assert_equal
from gala import evaluate as ev
def test_contingency_table():
seg = np.array([0, 1, 1, 1, 2, 2, 2, 3])
gt = np.array([1, 1, 1, 2, 2, 2, 2, 0])
ct = ev.contingency_table(seg, gt, ignore_seg=[], ignore_gt=[])
ct0 = ev.contingency_table(seg, gt, ig... | import numpy as np
from numpy.testing import assert_equal
from gala import evaluate as ev
def test_contingency_table():
seg = np.array([0, 1, 1, 1, 2, 2, 2, 3])
gt = np.array([1, 1, 1, 2, 2, 2, 2, 0])
ct = ev.contingency_table(seg, gt, ignore_seg=[], ignore_gt=[])
ct0 = ev.contingency_table(seg, gt, ig... | Add basic test to assert same shape of seg and gt | Add basic test to assert same shape of seg and gt
| Python | bsd-3-clause | jni/gala,janelia-flyem/gala | ---
+++
@@ -19,3 +19,9 @@
seg = np.array([1, 2, 3, 4])
gt = np.array([1, 1, 8, 8])
assert_equal(ev.vi(seg, gt), 1)
+
+def test_are():
+ seg = np.eye(3)
+ gt = np.eye(3)
+ seg[1][1] = 0
+ assert seg.shape == gt.shape |
1ac69ebb2b1ea3218f5c01338af3df86f3828090 | jarvis-system/orchestrator/src/asyncworker.py | jarvis-system/orchestrator/src/asyncworker.py | # Gets a list of services from the service resolver for each query. The module then
# requests each service with the query in async fashion and returns a json response
import requests
import string
import responsefilter
def do(service_dict):
url = _get_service_url(service_dict)
return responsefilter.do(service_dic... | # Gets a list of services from the service resolver for each query. The module then
# requests each service with the query in async fashion and returns a json response
import requests
import string
import responsefilter
def do(service_dict):
url = _get_service_url(service_dict)
return responsefilter.do(service_dic... | Fix bug in url creation. | Fix bug in url creation.
| Python | mit | lahsivjar/jarvis-kube | ---
+++
@@ -17,7 +17,7 @@
url_builder.append('.svc.cluster.local:')
url_builder.append(service_dict['service_port'])
url_builder.append(service_dict['endpoint'])
- url_builder.append('?')
+ url_builder.append('?query=')
url_builder.append(service_dict['query'])
return string.join(url_builder, '') |
96755c5e3ccf0573e7190da2a4a9264fdf409710 | linter.py | linter.py | #
# linter.py
# Markdown Linter for SublimeLinter, a code checking framework
# for Sublime Text 3
#
# Written by Jon LaBelle
# Copyright (c) 2018 Jon LaBelle
#
# License: MIT
#
"""This module exports the Markdownlint plugin class."""
from SublimeLinter.lint import NodeLinter, util
class MarkdownLint(NodeLinter):
... | #
# linter.py
# Markdown Linter for SublimeLinter, a code checking framework
# for Sublime Text 3
#
# Written by Jon LaBelle
# Copyright (c) 2018 Jon LaBelle
#
# License: MIT
#
"""This module exports the Markdownlint plugin class."""
from SublimeLinter.lint import NodeLinter, util
class MarkdownLint(NodeLinter):
... | Remove deprecated SL 'syntax' property override | Remove deprecated SL 'syntax' property override
Replaced by 'defaults/selector':
http://www.sublimelinter.com/en/stable/linter_settings.html#selector
| Python | mit | jonlabelle/SublimeLinter-contrib-markdownlint,jonlabelle/SublimeLinter-contrib-markdownlint | ---
+++
@@ -16,8 +16,12 @@
class MarkdownLint(NodeLinter):
"""Provides an interface to markdownlint."""
-
- syntax = ('markdown', 'markdown gfm', 'multimarkdown', 'markdown extended')
+ defaults = {
+ 'selector': 'text.html.markdown,'
+ 'text.html.markdown.multimarkdown,'
+ ... |
9b2ee2e4a956f8409047b289ee5c35ad4fcb4310 | insanity/layers.py | insanity/layers.py | import numpy as np
import theano
import theano.tensor as T
from theano.tensor.nnet import conv
from theano.tensor.nnet import softmax
from theano.tensor import shared_randomstreams
from theano.tensor.signal import downsample
class NeuralNetworkLayer(object):
def __init__(self, numInputs, input, inputDropout, numNe... | import numpy as np
import theano
import theano.tensor as T
from theano.tensor.nnet import conv
from theano.tensor.nnet import softmax
from theano.tensor import shared_randomstreams
from theano.tensor.signal import downsample
class Layer(object):
def __init__(self, numInputs, numNeurons, activation):
self.numInpu... | Add @property for network layer inputs | Add @property for network layer inputs
| Python | cc0-1.0 | cn04/insanity | ---
+++
@@ -8,22 +8,18 @@
-class NeuralNetworkLayer(object):
+class Layer(object):
- def __init__(self, numInputs, input, inputDropout, numNeurons, activation, miniBatchSize, dropoutAmount=0.0):
+ def __init__(self, numInputs, numNeurons, activation):
self.numInputs = numInputs
- self.input = input
- sel... |
f707f0daec148ae16604a8fb1326fe10155d4453 | tunobase/corporate/company_info/contact/tasks.py | tunobase/corporate/company_info/contact/tasks.py | """
CONTACT APP
This module provides a variety of tasks to be queued by Celery.
Classes:
n/a
Functions:
email_contact_message
Created on 21 Oct 2013
@author: michael
"""
from celery.decorators import task
from django.conf import settings
from tunobase.mailer import utils as mailer_utils
@task(defau... | """
CONTACT APP
This module provides a variety of tasks to be queued by Celery.
Classes:
n/a
Functions:
email_contact_message
Created on 21 Oct 2013
@author: michael
"""
from celery.decorators import task
from django.conf import settings
from tunobase.mailer import utils as mailer_utils
@task(defau... | Send contact us message from the email the user inputted on the site or use the default setting | Send contact us message from the email the user inputted on the site or use the default setting
| Python | bsd-3-clause | unomena/tunobase,unomena/tunobase | ---
+++
@@ -43,6 +43,7 @@
html_content='email/html/contact_message.html',
text_content='email/txt/contact_message.txt',
context=ctx_dict,
+ from_address=contact_message.email or settings.CONTACT_MESSAGE_TO_EMAIL,
to_addresses=[settings.CONTACT_MESSAGE_TO_... |
d410c30ba779ac0b32fdac7bf15733b1edacafe7 | src/weitersager/util.py | src/weitersager/util.py | """
weitersager.util
~~~~~~~~~~~~~~~~
Utilities
:Copyright: 2007-2021 Jochen Kupperschmidt
:License: MIT, see LICENSE for details.
"""
import logging
from logging import Formatter, StreamHandler
from threading import Thread
from typing import Callable
def configure_logging(level: str) -> None:
"""Configure app... | """
weitersager.util
~~~~~~~~~~~~~~~~
Utilities
:Copyright: 2007-2021 Jochen Kupperschmidt
:License: MIT, see LICENSE for details.
"""
import logging
from logging import Formatter, StreamHandler
from threading import Thread
from typing import Callable, Optional
def configure_logging(level: str) -> None:
"""Con... | Make thread name argument optional | Make thread name argument optional
| Python | mit | homeworkprod/weitersager | ---
+++
@@ -11,7 +11,7 @@
import logging
from logging import Formatter, StreamHandler
from threading import Thread
-from typing import Callable
+from typing import Callable, Optional
def configure_logging(level: str) -> None:
@@ -31,7 +31,7 @@
pkg_logger.setLevel(level)
-def start_thread(target: Call... |
4ac3c1d5feaadd46a13bc78f9834c29a789e0d9a | manage.py | manage.py | #!/usr/bin/env python
import os
import unittest
from flask.ext.script import Manager, Server
from app import app
manager = Manager(app)
server = Server(host='0.0.0.0', use_debugger=True)
manager.add_command("runserver", server)
@manager.command
def test():
"""Runs all the tests"""
parent_dir = os.path.dir... | #!/usr/bin/env python
import os
import sys
import unittest
from flask.ext.script import Manager, Server
from app import app
manager = Manager(app)
server = Server(host='0.0.0.0', use_debugger=True)
manager.add_command("runserver", server)
@manager.command
def test():
"""Runs all the tests"""
parent_dir = ... | Set the exit code when running tests correctly | Set the exit code when running tests correctly
| Python | mit | andytom/snippets,andytom/snippets | ---
+++
@@ -1,5 +1,6 @@
#!/usr/bin/env python
import os
+import sys
import unittest
from flask.ext.script import Manager, Server
from app import app
@@ -19,6 +20,8 @@
test_dir = os.path.join(parent_dir, 'tests')
tests = unittest.TestLoader().discover(test_dir)
results = unittest.TextTestRunner(ver... |
530549f7fe2c6bbf45996e17b2b125150ad031ae | manage.py | manage.py | #!/usr/bin/env python
"""
Run the Varda REST server.
To reset the database:
from varda import db
db.drop_all()
db.create_all()
"""
from flaskext.script import Manager
from flaskext.celery import install_commands as install_celery_commands
from varda import app, db
manager = Manager(app)
install_cele... | #!/usr/bin/env python
"""
Run the Varda REST server.
To setup the database:
create database varda;
create database vardacelery;
create database vardaresults;
grant all privileges on varda.* to varda@localhost identified by 'varda';
grant all privileges on vardacelery.* to varda@localhost identifie... | Add some notes on database setup | Add some notes on database setup
| Python | mit | varda/varda,sndrtj/varda | ---
+++
@@ -1,6 +1,15 @@
#!/usr/bin/env python
"""
Run the Varda REST server.
+
+To setup the database:
+
+ create database varda;
+ create database vardacelery;
+ create database vardaresults;
+ grant all privileges on varda.* to varda@localhost identified by 'varda';
+ grant all privileges on vard... |
830e1a23559b82af37f52657484edd20641318c5 | teamsupport/__init__.py | teamsupport/__init__.py | # -*- coding: utf-8 -*-
from __future__ import absolute_import
from teamsupport.services import TeamSupportService
__author__ = 'Yola Engineers'
__email__ = 'engineers@yola.com'
__version__ = '0.1.0'
__all__ = (TeamSupportService,)
| # -*- coding: utf-8 -*-
from __future__ import absolute_import
from teamsupport.models import Action, Ticket
from teamsupport.services import TeamSupportService
__author__ = 'Yola Engineers'
__email__ = 'engineers@yola.com'
__version__ = '0.1.0'
__all__ = (Action, TeamSupportService, Ticket,)
| Add convenience imports for models | Add convenience imports for models
| Python | mit | zoidbergwill/teamsupport-python,yola/teamsupport-python | ---
+++
@@ -1,10 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
+from teamsupport.models import Action, Ticket
from teamsupport.services import TeamSupportService
__author__ = 'Yola Engineers'
__email__ = 'engineers@yola.com'
__version__ = '0.1.0'
-__all__ = (TeamSupportService,)
... |
0b0a11d01378368fb795c117ffd931811eaf9b76 | pyhunter/exceptions.py | pyhunter/exceptions.py |
class PyhunterError(Exception):
"""
Generic exception class for the library
"""
pass
class MissingCompanyError(PyhunterError):
pass
class MissingNameError(PyhunterError):
pass
class HunterApiError(PyhunterError):
"""
Represents something went wrong in the call to the Hunter API
... | class PyhunterError(Exception):
"""
Generic exception class for the library
"""
pass
class MissingCompanyError(PyhunterError):
pass
class MissingNameError(PyhunterError):
pass
class HunterApiError(PyhunterError):
"""
Represents something went wrong in the call to the Hunter API
... | Add new line at end of file | Add new line at end of file
| Python | mit | VonStruddle/PyHunter | ---
+++
@@ -1,4 +1,3 @@
-
class PyhunterError(Exception):
"""
Generic exception class for the library |
404d499877c050f706ca0f713d1c8ef0e5a88889 | ooni/tests/bases.py | ooni/tests/bases.py | from twisted.trial import unittest
from ooni.settings import config
class ConfigTestCase(unittest.TestCase):
def setUp(self):
config.initialize_ooni_home("ooni_home")
def tearDown(self):
config.read_config_file() | import os
from twisted.trial import unittest
from ooni.settings import config
class ConfigTestCase(unittest.TestCase):
def setUp(self):
config.global_options['datadir'] = os.path.join(__file__, '..', '..', '..', 'data')
config.global_options['datadir'] = os.path.abspath(config.global_options['da... | Set the datadirectory to be that of the repo. | Set the datadirectory to be that of the repo.
| Python | bsd-2-clause | kdmurray91/ooni-probe,lordappsec/ooni-probe,Karthikeyan-kkk/ooni-probe,lordappsec/ooni-probe,Karthikeyan-kkk/ooni-probe,juga0/ooni-probe,juga0/ooni-probe,kdmurray91/ooni-probe,Karthikeyan-kkk/ooni-probe,lordappsec/ooni-probe,0xPoly/ooni-probe,0xPoly/ooni-probe,juga0/ooni-probe,Karthikeyan-kkk/ooni-probe,0xPoly/ooni-pro... | ---
+++
@@ -1,3 +1,5 @@
+import os
+
from twisted.trial import unittest
from ooni.settings import config
@@ -5,6 +7,8 @@
class ConfigTestCase(unittest.TestCase):
def setUp(self):
+ config.global_options['datadir'] = os.path.join(__file__, '..', '..', '..', 'data')
+ config.global_options['da... |
eacc1f88f7e34e26c3a4d29ec009b4984c10a345 | SimPEG/Mesh/__init__.py | SimPEG/Mesh/__init__.py | from TensorMesh import TensorMesh
from CylMesh import CylMesh
from Cyl1DMesh import Cyl1DMesh
from LogicallyRectMesh import LogicallyRectMesh
from TreeMesh import TreeMesh
from BaseMesh import BaseMesh
| from TensorMesh import TensorMesh
from CylMesh import CylMesh
from LogicallyRectMesh import LogicallyRectMesh
from TreeMesh import TreeMesh
from BaseMesh import BaseMesh
| Remove Cyl1DMesh from init file... | Remove Cyl1DMesh from init file...
| Python | mit | simpeg/discretize,simpeg/simpeg,simpeg/discretize,simpeg/discretize | ---
+++
@@ -1,6 +1,5 @@
from TensorMesh import TensorMesh
from CylMesh import CylMesh
-from Cyl1DMesh import Cyl1DMesh
from LogicallyRectMesh import LogicallyRectMesh
from TreeMesh import TreeMesh
from BaseMesh import BaseMesh |
26330025ccdeab7febd69c7f9053a99ac46d421b | cactus/static/external/manager.py | cactus/static/external/manager.py | class ExternalManager(object):
"""
Manager the active externals
"""
def __init__(self, processors=None, optimizers=None):
self.processors = processors if processors is not None else []
self.optimizers = optimizers if optimizers is not None else []
def _register(self, external, exter... | class ExternalManager(object):
"""
Manager the active externals
"""
def __init__(self, processors=None, optimizers=None):
self.processors = processors if processors is not None else []
self.optimizers = optimizers if optimizers is not None else []
def _register(self, external, exter... | Add option to unregister externals | Add option to unregister externals
| Python | bsd-3-clause | page-io/Cactus,juvham/Cactus,ibarria0/Cactus,gone/Cactus,Knownly/Cactus,ibarria0/Cactus,dreadatour/Cactus,danielmorosan/Cactus,PegasusWang/Cactus,dreadatour/Cactus,andyzsf/Cactus-,Bluetide/Cactus,koenbok/Cactus,Knownly/Cactus,PegasusWang/Cactus,koobs/Cactus,ibarria0/Cactus,eudicots/Cactus,page-io/Cactus,chaudum/Cactus,... | ---
+++
@@ -8,6 +8,9 @@
def _register(self, external, externals):
externals.insert(0, external)
+
+ def _deregister(self, external, externals):
+ externals.remove(external)
def clear(self):
"""
@@ -23,9 +26,23 @@
"""
self._register(processor, self.processors... |
d48e1388eb2a21f83094e561405e292f6ecc3fb9 | labkey/__init__.py | labkey/__init__.py | #
# Copyright (c) 2011-2014 LabKey Corporation
#
# 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 agre... | #
# Copyright (c) 2011-2014 LabKey Corporation
#
# 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 agre... | Include utils in base import | Include utils in base import
| Python | apache-2.0 | LabKey/labkey-api-python | ---
+++
@@ -13,7 +13,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
-from labkey import query, experiment # wiki, messageboard
+from labkey import query, experiment, utils # wiki, messageboard
from pkg_resources import get_distribution
__title__ ... |
962ae8a53c95e8ade1e0fd5804062b807837781e | pycalc.py | pycalc.py | # vim: set fileencoding=utf-8
import sys
try:
import readline
# No idea if this is a license violation. Hope it isn't.
except ImportError:
print("Could not find readline, you will likely get no line editing functionality")
if sys.version_info.major < 3:
print("This program is for python version 3 onl... | # vim: set fileencoding=utf-8
import sys
try:
import readline # noqa: this is used simply by being imported.
# No idea if this is a license violation. Hope it isn't.
except ImportError:
print("Could not find readline, you will likely get no line editing functionality")
if sys.version_info.major < 3:
... | Add lines to shut flake8 up. | Add lines to shut flake8 up.
| Python | mit | 5225225/pycalc,5225225/pycalc | ---
+++
@@ -3,7 +3,7 @@
import sys
try:
- import readline
+ import readline # noqa: this is used simply by being imported.
# No idea if this is a license violation. Hope it isn't.
except ImportError:
print("Could not find readline, you will likely get no line editing functionality")
@@ -12,8 +12... |
2f03aa69f55d4d899af968e57a59a58d27ef82c8 | url_shortener/forms.py | url_shortener/forms.py | # -*- coding: utf-8 -*-
from flask_wtf import Form
from flask_wtf.recaptcha import RecaptchaField, Recaptcha
from wtforms import StringField, validators
from .validation import not_blacklisted_nor_spam
class ShortenedURLForm(Form):
url = StringField(
validators=[
validators.DataRequired(),
... | # -*- coding: utf-8 -*-
from flask_wtf import Form
from flask_wtf.recaptcha import RecaptchaField, Recaptcha
from wtforms import StringField, validators
from .validation import not_blacklisted_nor_spam
class ShortenedURLForm(Form):
url = StringField(
validators=[
validators.DataRequired(),
... | Add placeholder text to URL form field | Add placeholder text to URL form field
| Python | mit | piotr-rusin/url-shortener,piotr-rusin/url-shortener | ---
+++
@@ -12,7 +12,8 @@
validators.DataRequired(),
validators.URL(message='A valid URL is required'),
not_blacklisted_nor_spam
- ]
+ ],
+ render_kw={'placeholder': 'Original URL'}
)
recaptcha = RecaptchaField(
validators=[ |
43e4d71a193f78e83f26e9d1c5fe69cee1b289b5 | raffle.py | raffle.py | # -*- coding: utf-8 -*-
import random
import webbrowser
from pythonkc_meetups import PythonKCMeetups
from optparse import OptionParser
def raffle_time(api_key=None, event_id=None):
client = PythonKCMeetups(api_key=api_key)
attendees = client.get_event_attendees(event_id)
random.shuffle(attendees)
win... | # -*- coding: utf-8 -*-
import random
import webbrowser
from pythonkc_meetups import PythonKCMeetups
from optparse import OptionParser
def raffle_time(api_key=None, event_id=None):
client = PythonKCMeetups(api_key=api_key)
attendees = client.get_event_attendees(event_id)
random.seed()
random.shuffle(... | Add call to random.seed() and change print statement to print function. | Add call to random.seed() and change print statement to print function.
| Python | bsd-3-clause | pythonkc/pythonkc-raffler | ---
+++
@@ -9,11 +9,12 @@
def raffle_time(api_key=None, event_id=None):
client = PythonKCMeetups(api_key=api_key)
attendees = client.get_event_attendees(event_id)
+ random.seed()
random.shuffle(attendees)
winner = random.choice(attendees)
if winner.photo:
webbrowser.open_new(winn... |
c7b40736b6e59a654652afaab7fb643e00c1f186 | clients/cron/call_uw_course_alerter.py | clients/cron/call_uw_course_alerter.py | import subprocess
import urllib
def main():
api_url = 'https://uw-alert.herokuapp.com/check_availability'
courses = [{'level': 'under',
'session': 1151,
'subject': 'CS',
'number': 341,
'email': 'youremail@example.com'}]
for course in courses:
... | #!/usr/bin/env python
import subprocess
import urllib
def main():
api_url = 'https://uw-alert.herokuapp.com/check_availability'
courses = [{'level': 'under',
'session': 1151,
'subject': 'CS',
'number': 341,
'email': 'youremail@example.com'}]
... | Add shebang for Python to sample script | Add shebang for Python to sample script
| Python | mit | tuzhucheng/uw-course-alerter,tuzhucheng/uw-course-alerter,tuzhucheng/uw-course-alerter,tuzhucheng/uw-course-alerter | ---
+++
@@ -1,3 +1,5 @@
+#!/usr/bin/env python
+
import subprocess
import urllib
|
9b524fa97d1d1c8c132d1a880103a5ab4d0dabfc | models.py | models.py | from google.appengine.ext import ndb
class Photo(ndb.Model):
name = ndb.StringProperty()
blob_info_key = ndb.BlobKeyProperty()
date_created = ndb.DateTimeProperty(auto_now_add=True)
class Album(ndb.Model):
name = ndb.StringProperty()
description = ndb.StringProperty()
date_created = ndb.Date... | from google.appengine.ext import ndb
class Photo(ndb.Model):
name = ndb.StringProperty()
blob_info_key = ndb.BlobKeyProperty()
date_created = ndb.DateTimeProperty(auto_now_add=True)
class Album(ndb.Model):
name = ndb.StringProperty()
description = ndb.StringProperty()
date_created = ndb.Date... | Add Comment Model for Photo and Album | Add Comment Model for Photo and Album
| Python | mit | MichaelAquilina/Photo-Nebula,MichaelAquilina/Photo-Nebula | ---
+++
@@ -11,3 +11,9 @@
name = ndb.StringProperty()
description = ndb.StringProperty()
date_created = ndb.DateTimeProperty(auto_now_add=True)
+
+
+class Comment(ndb.Model):
+ author = ndb.StringProperty()
+ text = ndb.StringProperty()
+ date_created = ndb.DateTimeProperty(auto_now_add=True) |
3c04509ced5c51c55294e88ded2614b9f289deea | launch_instance.py | launch_instance.py | import boto3
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
ec2 = boto3.resource('ec2')
with open('env.sh') as e, open('cloud-init.sh') as f:
script = e.read() + f.read()
instance = ec2.create_instances(
ImageId='ami... | import boto3
import logging
logger = logging.getLogger()
logger.setLevel(logging.INFO)
def lambda_handler(event, context):
ec2 = boto3.resource('ec2')
with open('env.sh') as e, open('cloud-init.sh') as f:
script = e.read() + f.read()
instance = ec2.create_instances(
ImageId='ami... | Upgrade instance type due to RAM issues | Upgrade instance type due to RAM issues
| Python | mit | gertvv/ictrp-retrieval,gertvv/ictrp-retrieval | ---
+++
@@ -17,7 +17,7 @@
KeyName='ictrp',
UserData=script,
SecurityGroups=['launch-wizard-1'],
- InstanceType='t2.micro',
+ InstanceType='t3.small',
InstanceInitiatedShutdownBehavior='terminate')
logging.info(instance[0]) |
d5e5b9ca4c9243d950e17b141008ffb168df0b64 | kbkdna/dna.py | kbkdna/dna.py | #!/usr/bin/env python2
from __future__ import division
def reverse(seq):
"""Return the reverse of the given sequence (i.e. 3' to
5')."""
return seq[::-1]
def complement(seq):
"""Return the complement of the given sequence (i.e. G=>C,
A=>T, etc.)"""
from string import maketrans
complemen... | #!/usr/bin/env python2
def reverse(seq):
"""Return the reverse of the given sequence (i.e. 3' to
5')."""
return seq[::-1]
def complement(seq):
"""Return the complement of the given sequence (i.e. G=>C,
A=>T, etc.)"""
from string import maketrans
complements = maketrans('ACTGactg', 'TGACt... | Put the gc_content bug back. | Put the gc_content bug back.
| Python | mit | kalekundert/kbkdna | ---
+++
@@ -1,6 +1,4 @@
#!/usr/bin/env python2
-
-from __future__ import division
def reverse(seq):
"""Return the reverse of the given sequence (i.e. 3' to |
34274289f0cbfafbb1d762cad38a7225873d6850 | matches/admin.py | matches/admin.py | from django.contrib import admin
from .models import Match
from .models import Tip
def delete_tips(modeladmin, request, queryset):
for match in queryset:
tips = Tip.object.filter(match = match)
for tip in tips:
tip.score = 0
tip.scoring_field = ""
tip.is_score_ca... | from django.contrib import admin
from .models import Match
from .models import Tip
def delete_tips(modeladmin, request, queryset):
for match in queryset:
tips = Tip.object.filter(match = match)
for tip in tips:
tip.score = 0
tip.scoring_field = ""
tip.is_score_ca... | Add action to zero out tips for given match | Add action to zero out tips for given match
| Python | mit | leventebakos/football-ech,leventebakos/football-ech | ---
+++
@@ -12,7 +12,7 @@
delete_tips.delete_tips = "Delete calculated scores for tips for these matches"
class MatchAdmin(admin.ModelAdmin):
- actions = [make_published]
+ actions = [delete_tips]
admin.site.register(Match, MatchAdmin)
admin.site.register(Tip) |
88921deb630bef702a08f5b3a07279ccd223902b | test/lifecycle_test.py | test/lifecycle_test.py | from threading import Thread
from Queue import Queue
from doubles import lifecycle
class TestLifecycle(object):
def test_stores_a_space_per_thread(self):
queue = Queue()
queue.put(lifecycle.current_space())
def push_thread_space_to_queue(queue):
queue.put(lifecycle.current_s... | from threading import Thread
from Queue import Queue
from doubles import lifecycle
class TestLifecycle(object):
def test_stores_a_space_per_thread(self):
queue = Queue()
def push_thread_space_to_queue(queue):
queue.put(lifecycle.current_space())
push_thread_space_to_queue(qu... | Reduce minor duplication in lifecycle test. | Reduce minor duplication in lifecycle test.
| Python | mit | uber/doubles | ---
+++
@@ -8,10 +8,10 @@
def test_stores_a_space_per_thread(self):
queue = Queue()
- queue.put(lifecycle.current_space())
-
def push_thread_space_to_queue(queue):
queue.put(lifecycle.current_space())
+
+ push_thread_space_to_queue(queue)
thread = Thread(... |
0335f32fa7035d394a6434b924a8ebb17332fd45 | mist/__init__.py | mist/__init__.py | import requests
class Bit:
def __init__(self, auth_token, device_id):
self.token = auth_token
self.id = device_id
self.version = '0.1.0'
self.headers = {"Authorization": "Bearer " + self.token, "Accept": "application/vnd.littlebits.v2+json"}
def output(self, pct, dur):
... | import requests
print """
mist - a python wrapper for the cloudBit API.
If you use this, please let me know on github!
http://github.com/technoboy10/mist
"""
class Bit:
def __init__(self, auth_token, device_id):
self.token = auth_token
self.id = device_id
self.version = '0.1.0'
self... | Print stuff when module is imported. | Print stuff when module is imported.
| Python | mit | technoboy10/partly-cloudy | ---
+++
@@ -1,4 +1,10 @@
import requests
+print """
+mist - a python wrapper for the cloudBit API.
+
+If you use this, please let me know on github!
+http://github.com/technoboy10/mist
+"""
class Bit:
def __init__(self, auth_token, device_id):
self.token = auth_token |
1843e34bba0343cd3600f3c8934ae29b4b365554 | chstrings/chstrings_test.py | chstrings/chstrings_test.py | import chstrings
import config
import unittest
class CHStringsTest(unittest.TestCase):
@classmethod
def add_smoke_test(cls, cfg):
def test(self):
# We just want to see if this will blow up
chstrings.get_localized_strings(cfg, cfg.lang_code)
name = 'test_' + cfg.lang_cod... | import chstrings
import config
import unittest
class CHStringsTest(unittest.TestCase):
@classmethod
def add_smoke_test(cls, cfg):
def test(self):
# We just want to see if this will blow up. Use the fallback
# lang_tag across all tests.
lang_tag = cfg.lang_code
... | Extend chstrings smoke test a little more. | Extend chstrings smoke test a little more.
| Python | mit | eggpi/citationhunt,guilherme-pg/citationhunt,eggpi/citationhunt,eggpi/citationhunt,guilherme-pg/citationhunt,guilherme-pg/citationhunt,eggpi/citationhunt,guilherme-pg/citationhunt | ---
+++
@@ -7,8 +7,13 @@
@classmethod
def add_smoke_test(cls, cfg):
def test(self):
- # We just want to see if this will blow up
- chstrings.get_localized_strings(cfg, cfg.lang_code)
+ # We just want to see if this will blow up. Use the fallback
+ # lang_... |
a47e300d9e25dd3f631c9538f33b1d65cca847af | profile_collection/startup/80-areadetector.py | profile_collection/startup/80-areadetector.py | from ophyd.controls.area_detector import (AreaDetectorFileStoreHDF5,
AreaDetectorFileStoreTIFF,
AreaDetectorFileStoreTIFFSquashing)
# from shutter import sh1
shctl1 = EpicsSignal('XF:28IDC-ES:1{Det:PE1}cam1:ShutterMode', name='shctl1'... | from ophyd.controls.area_detector import (AreaDetectorFileStoreHDF5,
AreaDetectorFileStoreTIFF,
AreaDetectorFileStoreTIFFSquashing)
# from shutter import sh1
shctl1 = EpicsSignal('XF:28IDC-ES:1{Det:PE1}cam1:ShutterMode', name='shctl1'... | Update ioc storage path for the raw tiffs. | Update ioc storage path for the raw tiffs.
| Python | bsd-2-clause | pavoljuhas/ipython_ophyd,pavoljuhas/ipython_ophyd,NSLS-II-XPD/ipython_ophyd,NSLS-II-XPD/ipython_ophyd | ---
+++
@@ -10,7 +10,7 @@
'XF:28IDC-ES:1{Det:PE1}',
name='pe1',
stats=[],
- ioc_file_path = 'G:/pe1_data',
+ ioc_file_path = 'H:/pe1_data',
file_path = '/home/xf28id1/pe1_data',
shutter=shctl1,
shutter_val=(1, 0) |
46592a761df3716e5c3e218e4aa714bc7fc1b0ce | twilio.py | twilio.py | from twilio.rest import TwilioRestClient
import config
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(to="+12316851234", from_="+15555555555",
body="Hello there!") | from twilio.rest import TwilioRestClient
import config
client = TwilioRestClient(account_sid, auth_token)
message = client.messages.create(to="+12316851234", from_="+15555555555",
body="Hello there!")
| Add newline at end of file | Add newline at end of file
| Python | mit | nhshd-slot/SLOT,bsharif/SLOT,bsharif/SLOT,nhshd-slot/SLOT,bsharif/SLOT,nhshd-slot/SLOT | |
8bd562b3ae6a2e5ae4fd1ad88da5d46408415365 | cliche/services/__init__.py | cliche/services/__init__.py | """:mod:`cliche.services` --- Interfacing external services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How to add a new external service
---------------------------------
In order to add a new service to cliche, you must create a subpackage under
:data:`cliche.services` and expose some methods referr... | """:mod:`cliche.services` --- Interfacing external services
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
How to add a new external service
---------------------------------
In order to add a new service to cliche, you must create a subpackage under
:data:`cliche.services` and expose some methods referr... | Add some details to docs | Add some details to docs
| Python | mit | clicheio/cliche,item4/cliche,clicheio/cliche,item4/cliche,clicheio/cliche | ---
+++
@@ -13,7 +13,8 @@
- :func:`sync()`: Method to delay a main crawling task to the queue. It should
be decorated with :code:`@app.task` to be defined as a celery app worker
- task.
+ task. It should have no arguments and no return. Every output should be made
+ as a log to celery logger.
Example :fil... |
4add4eb1895498d547c8cf86ea8017c273932139 | petition/forms.py | petition/forms.py | from django.forms import ModelForm
from django import forms
from django.forms.widgets import TextInput
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from braces.forms import UserKwargModelFormMixin
from crispy_forms.helper import FormHelper
from crispy_forms.layout impo... | from django.forms import ModelForm
from django import forms
from django.forms.widgets import TextInput
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext as _
from braces.forms import UserKwargModelFormMixin
from crispy_forms.helper import FormHelper
from crispy_forms.layout impo... | Add a class for sign button | Add a class for sign button
What will make it easier to manipulate the theme | Python | mit | watchdogpolska/django-one-petition,watchdogpolska/django-one-petition,watchdogpolska/django-one-petition | ---
+++
@@ -22,7 +22,7 @@
self.helper = FormHelper()
self.helper.form_action = reverse('petition:create')
self.helper.form_method = 'post'
- self.helper.add_input(Submit('submit', _('Sign'), css_class="btn-lg btn-block"))
+ self.helper.add_input(Submit('submit', _('Sign'), css... |
bcd9799b790aef9571491c0537e5aeb12bc9a564 | make_a_plea/management/commands/check_urns_in_db.py | make_a_plea/management/commands/check_urns_in_db.py | import csv
from django.core.management.base import BaseCommand
from apps.plea.models import DataValidation, Case
from apps.plea.standardisers import standardise_urn, format_for_region
class Command(BaseCommand):
help = "Build weekly aggregate stats"
def add_arguments(self, parser):
parser.add_argum... | from django.core.management.base import BaseCommand
from apps.plea.models import Case
from apps.plea.standardisers import standardise_urn
class Command(BaseCommand):
help = "Build weekly aggregate stats"
def add_arguments(self, parser):
parser.add_argument('csv_file', nargs='+')
def handle(self... | Update management command to check if a list of URNs is present in the database | Update management command to check if a list of URNs is present in the database
| Python | mit | ministryofjustice/manchester_traffic_offences_pleas,ministryofjustice/manchester_traffic_offences_pleas,ministryofjustice/manchester_traffic_offences_pleas,ministryofjustice/manchester_traffic_offences_pleas | ---
+++
@@ -1,9 +1,7 @@
-import csv
from django.core.management.base import BaseCommand
-
-from apps.plea.models import DataValidation, Case
-from apps.plea.standardisers import standardise_urn, format_for_region
+from apps.plea.models import Case
+from apps.plea.standardisers import standardise_urn
class Com... |
9eea896352e62850494dbb3f894eef0b82afab89 | needy/projects/boostbuild.py | needy/projects/boostbuild.py | import os
import subprocess
from .. import project
class BoostBuildProject(project.Project):
@staticmethod
def identifier():
return 'boostbuild'
@staticmethod
def is_valid_project(definition, needy):
if not definition.target.platform.is_host():
return False
if n... | import os
import subprocess
from .. import project
class BoostBuildProject(project.Project):
@staticmethod
def identifier():
return 'boostbuild'
@staticmethod
def is_valid_project(definition, needy):
if not definition.target.platform.is_host():
return False
if n... | Add support for linkage in b2 projects | Add support for linkage in b2 projects
| Python | mit | vmrob/needy,ccbrown/needy,vmrob/needy,bittorrent/needy,bittorrent/needy,ccbrown/needy | ---
+++
@@ -46,5 +46,9 @@
b2 = './b2' if os.path.isfile('b2') else 'b2'
b2_args = self.evaluate(self.configuration('b2-args'))
b2_args += self.get_build_concurrency_args()
+ if self.configuration('linkage') in ['static']:
+ b2_args += ['link=static']
+ elif self.con... |
cd88b3a695e87078aa0b50f9b3ea3af9ae3eb0a5 | databroker/tests/test_core.py | databroker/tests/test_core.py | from __future__ import absolute_import, division, print_function
from databroker.core import Header
def test_header_dict_conformance(db):
# TODO update this if / when we add conformance testing to
# validate attrs in Header
target = {'start': {'uid': 'start'},
'stop': {'uid': 'stop', 'start... | from __future__ import absolute_import, division, print_function
import copy
from databroker.core import Header
def test_header_dict_conformance(db):
db.prepare_hook = lambda name, doc: copy.deepcopy(doc)
# TODO update this if / when we add conformance testing to
# validate attrs in Header
target = ... | Remove doct from the equation in attrs tests. | TST: Remove doct from the equation in attrs tests.
| Python | bsd-3-clause | ericdill/databroker,ericdill/databroker | ---
+++
@@ -1,9 +1,12 @@
from __future__ import absolute_import, division, print_function
+import copy
from databroker.core import Header
def test_header_dict_conformance(db):
+ db.prepare_hook = lambda name, doc: copy.deepcopy(doc)
+
# TODO update this if / when we add conformance testing to
# ... |
4fdf3af6414ae6fdc20882309bcaf36ffbe5c7a7 | scripts/prereg/approve_draft_registrations.py | scripts/prereg/approve_draft_registrations.py | """ A script for testing DraftRegistrationApprovals. Automatically approves all pending
DraftRegistrationApprovals.
"""
import sys
import logging
from website.app import init_app
from website.models import DraftRegistration, Sanction, User
logger = logging.getLogger(__name__)
logging.basicConfig(level=logging.WARN)
l... | """ A script for testing DraftRegistrationApprovals. Automatically approves all pending
DraftRegistrationApprovals.
"""
import sys
import logging
from framework.tasks.handlers import celery_teardown_request
from website.app import init_app
from website.project.model import DraftRegistration, Sanction
logger = loggin... | Make sure celery_teardown_request gets called in DraftReg auto-approve script | Make sure celery_teardown_request gets called in DraftReg auto-approve script [skip ci]
| Python | apache-2.0 | crcresearch/osf.io,Johnetordoff/osf.io,TomHeatwole/osf.io,Nesiehr/osf.io,Nesiehr/osf.io,mattclark/osf.io,caneruguz/osf.io,zachjanicki/osf.io,caneruguz/osf.io,SSJohns/osf.io,adlius/osf.io,monikagrabowska/osf.io,abought/osf.io,crcresearch/osf.io,HalcyonChimera/osf.io,KAsante95/osf.io,aaxelb/osf.io,acshi/osf.io,KAsante95/... | ---
+++
@@ -4,8 +4,10 @@
import sys
import logging
+from framework.tasks.handlers import celery_teardown_request
+
from website.app import init_app
-from website.models import DraftRegistration, Sanction, User
+from website.project.model import DraftRegistration, Sanction
logger = logging.getLogger(__name__)
... |
579fbe76f8ab86d5f599f9888149fcaed297842c | src/sentry/celery.py | src/sentry/celery.py | from __future__ import absolute_import
import celery
import os
import os.path
import sys
# Add the project to the python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
# Configure the application only if it seemingly isnt already configured
from django.conf import settings
if not setting... | from __future__ import absolute_import
import celery
import os
import os.path
import sys
# Add the project to the python path
sys.path.insert(0, os.path.join(os.path.dirname(__file__), os.pardir))
# Configure the application only if it seemingly isnt already configured
from django.conf import settings
if not setting... | Use star args to invoke apply_async | Use star args to invoke apply_async
| Python | bsd-3-clause | zenefits/sentry,nicholasserra/sentry,fotinakis/sentry,JamesMura/sentry,alexm92/sentry,nicholasserra/sentry,BuildingLink/sentry,gencer/sentry,daevaorn/sentry,beeftornado/sentry,JamesMura/sentry,mvaled/sentry,jean/sentry,JamesMura/sentry,fotinakis/sentry,mvaled/sentry,JamesMura/sentry,beeftornado/sentry,looker/sentry,fot... | ---
+++
@@ -37,11 +37,11 @@
class SentryTask(OriginalTask):
- def apply_async(self, args, kwargs):
+ def apply_async(self, *args, **kwargs):
key = 'jobs.delay'
instance = self.name
with metrics.timer(key, instance=instance):
- return OriginalTask.apply_async(self, args... |
e9031ab6091e3b9d7866c300c8e21b9e81e7e935 | api/collections/urls.py | api/collections/urls.py | from django.conf.urls import url
from api.collections import views
from website import settings
urlpatterns = []
# Routes only active in local/staging environments
if settings.DEV_MODE:
urlpatterns.extend([
url(r'^$', views.CollectionList.as_view(), name='collection-list'),
url(r'^(?P<collection_... | from django.conf.urls import url
from api.collections import views
urlpatterns = [
url(r'^$', views.CollectionList.as_view(), name='collection-list'),
url(r'^(?P<collection_id>\w+)/$', views.CollectionDetail.as_view(), name='collection-detail'),
url(r'^(?P<collection_id>\w+)/linked_nodes/$', views.LinkedN... | Remove DEV ONLY on the sub view since the super already has it | Remove DEV ONLY on the sub view since the super already has it
| Python | apache-2.0 | cslzchen/osf.io,leb2dg/osf.io,kch8qx/osf.io,TomBaxter/osf.io,wearpants/osf.io,laurenrevere/osf.io,chrisseto/osf.io,cslzchen/osf.io,mluo613/osf.io,rdhyee/osf.io,mluke93/osf.io,adlius/osf.io,CenterForOpenScience/osf.io,pattisdr/osf.io,billyhunt/osf.io,mluo613/osf.io,caseyrollins/osf.io,zachjanicki/osf.io,jnayak1/osf.io,a... | ---
+++
@@ -1,16 +1,11 @@
from django.conf.urls import url
from api.collections import views
-from website import settings
-urlpatterns = []
-
-# Routes only active in local/staging environments
-if settings.DEV_MODE:
- urlpatterns.extend([
- url(r'^$', views.CollectionList.as_view(), name='collection... |
af9b7dd5e4923c15a8adbab41ee9933245714ec8 | python/example.py | python/example.py | #! /usr/bin/env python
from lsapi import lsapi
l = lsapi('my-access-id', 'my-secret-key')
# As you may have noticed, there are lots of columns available
# I did what I could to make them easily-accessible, but there
# are a lot, and the names are long. So, the API calls have
# defaults
# Let's get some URL metrics.... | #! /usr/bin/env python
from lsapi import lsapi
l = lsapi('my-access-id', 'my-secret-key')
# As you may have noticed, there are lots of columns available
# I did what I could to make them easily-accessible, but there
# are a lot, and the names are long. So, the API calls have
# defaults
# Let's get some URL metrics.... | Format keyword arguments like PEP-8. | Format keyword arguments like PEP-8.
| Python | mit | seomoz/SEOmozAPISamples,seomoz/SEOmozAPISamples,seomoz/SEOmozAPISamples,seomoz/SEOmozAPISamples,seomoz/SEOmozAPISamples,seomoz/SEOmozAPISamples | ---
+++
@@ -26,4 +26,4 @@
links = l.links('www.moz.com')
# The links API has more columns to specify, as well as sort, scope, etc.
links = l.links('www.moz.com', scope='domain_to_domain', sort='domain_authority',
- filters=['external', 'nofollow'], targetCols = lsapi.UMCols.url)
+ filters=['external', 'nofollow'],... |
610c27c15c09777a84143f551bb2cd3c2a5e3584 | nltk/align/util.py | nltk/align/util.py | # Natural Language Toolkit: Aligner Utilities
#
# Copyright (C) 2001-2013 NLTK Project
# Author:
# URL: <http://www.nltk.org/>
# For license information, see LICENSE.TXT
| # Natural Language Toolkit: Aligner Utilities
#
# Copyright (C) 2001-2013 NLTK Project
# Author:
# URL: <http://www.nltk.org/>
# For license information, see LICENSE.TXT
from nltk.align.api import Alignment
def pharaohtext2tuples(pharaoh_text):
"""
Converts pharaoh text format into an Alignment object (a list of t... | Convert pharaoh output format to Alignment object and vice versa:wq | Convert pharaoh output format to Alignment object and vice versa:wq
| Python | apache-2.0 | nltk/nltk,nltk/nltk,nltk/nltk | ---
+++
@@ -5,3 +5,48 @@
# URL: <http://www.nltk.org/>
# For license information, see LICENSE.TXT
+from nltk.align.api import Alignment
+
+def pharaohtext2tuples(pharaoh_text):
+ """
+ Converts pharaoh text format into an Alignment object (a list of tuples).
+
+ >>> pharaoh_text = '0-0 2-1 9-2 21-3 10-4 7-5'
+ ... |
59eb6eaf18c67c424dad35f82f6baac6c93de380 | elasticmock/__init__.py | elasticmock/__init__.py | # -*- coding: utf-8 -*-
from functools import wraps
from mock import patch
from elasticmock.fake_elasticsearch import FakeElasticsearch
ELASTIC_INSTANCES = {}
def _get_elasticmock(hosts=None, *args, **kwargs):
elastic_key = 'localhost:9200' if hosts is None else '{0}:{1}'.format(hosts[0].get('host'), hosts[0]... | # -*- coding: utf-8 -*-
from functools import wraps
from elasticsearch.client import _normalize_hosts
from mock import patch
from elasticmock.fake_elasticsearch import FakeElasticsearch
ELASTIC_INSTANCES = {}
def _get_elasticmock(hosts=None, *args, **kwargs):
host = _normalize_hosts(hosts)[0]
elastic_key ... | Allow the same 'hosts' settings that Elasticsearch does | Allow the same 'hosts' settings that Elasticsearch does
| Python | mit | vrcmarcos/elasticmock | ---
+++
@@ -2,6 +2,7 @@
from functools import wraps
+from elasticsearch.client import _normalize_hosts
from mock import patch
from elasticmock.fake_elasticsearch import FakeElasticsearch
@@ -10,7 +11,11 @@
def _get_elasticmock(hosts=None, *args, **kwargs):
- elastic_key = 'localhost:9200' if hosts is... |
7d10b9d803089d1cf8a0c06219608d31bf5fb84f | src/collectors/MongoDBCollector/MongoDBCollector.py | src/collectors/MongoDBCollector/MongoDBCollector.py | try:
from numbers import Number
import pymongo
except ImportError:
Number = None
import diamond
class MongoDBCollector(diamond.collector.Collector):
"""Collects data from MongoDB's db.serverStatus() command
Collects all number values from the db.serverStatus() command, other
values are ignor... | try:
from numbers import Number
import pymongo
from pymongo import ReadPreference
except ImportError:
Number = None
import diamond
class MongoDBCollector(diamond.collector.Collector):
"""Collects data from MongoDB's db.serverStatus() command
Collects all number values from the db.serverStatu... | Replace deprecated slave_ok for read_preference in pymongo.Connection | Replace deprecated slave_ok for read_preference in pymongo.Connection
See: http://api.mongodb.org/python/current/api/pymongo/connection.html
| Python | mit | jriguera/Diamond,MichaelDoyle/Diamond,Netuitive/netuitive-diamond,hamelg/Diamond,dcsquared13/Diamond,sebbrandt87/Diamond,python-diamond/Diamond,gg7/diamond,sebbrandt87/Diamond,actmd/Diamond,signalfx/Diamond,Basis/Diamond,bmhatfield/Diamond,python-diamond/Diamond,krbaker/Diamond,jumping/Diamond,signalfx/Diamond,rtoma/Di... | ---
+++
@@ -1,6 +1,7 @@
try:
from numbers import Number
import pymongo
+ from pymongo import ReadPreference
except ImportError:
Number = None
@@ -31,7 +32,7 @@
self.log.error('Unable to import either Number or pymongo')
return {}
- conn = pymongo.Connection(sel... |
ab5ebb50019add34333edb04cc96f7f55fce8d1c | src/toil/utils/__init__.py | src/toil/utils/__init__.py | from __future__ import absolute_import
from toil import version
import logging
logger = logging.getLogger(__name__)
def addBasicProvisionerOptions(parser):
parser.add_argument("--version", action='version', version=version)
parser.add_argument('-p', "--provisioner", dest='provisioner', choices=['aws', 'azur... | from __future__ import absolute_import
from toil import version
import logging
import os
logger = logging.getLogger(__name__)
def addBasicProvisionerOptions(parser):
parser.add_argument("--version", action='version', version=version)
parser.add_argument('-p', "--provisioner", dest='provisioner', choices=['aw... | Remove default for zone, add method for searching for specified zone in environ vars. | Remove default for zone, add method for searching for specified zone in environ vars.
| Python | apache-2.0 | BD2KGenomics/slugflow,BD2KGenomics/slugflow | ---
+++
@@ -2,7 +2,7 @@
from toil import version
import logging
-
+import os
logger = logging.getLogger(__name__)
@@ -11,19 +11,26 @@
parser.add_argument('-p', "--provisioner", dest='provisioner', choices=['aws', 'azure', 'gce'], required=False, default="aws",
help="The provisio... |
98d45ace5ce5b8918e470beb7dbcb1d59b0608af | server_app/__main__.py | server_app/__main__.py | import sys
import os
import logging
if not os.path.exists(os.path.expanduser("~/.chatserver")):
os.makedirs(os.path.expanduser("~/.chatserver")
logging.basicConfig(filename=os.path.expanduser("~/.chatserver/chat.log"), level=logging.DEBUG)
from app import app, db, main, socketio
db.create_all()
app.register_bluep... | import sys
import os
import logging
if not os.path.exists(os.path.expanduser("~/.chatserver")):
os.makedirs(os.path.expanduser("~/.chatserver"))
logging.basicConfig(filename=os.path.expanduser("~/.chatserver/chat.log"), level=logging.DEBUG)
from app import app, db, main, socketio
db.create_all()
app.register_blue... | Fix logging directory njot existing | Fix logging directory njot existing
| Python | bsd-3-clause | jos0003/Chat,jos0003/Chat,jos0003/Chat,jos0003/Chat,jos0003/Chat | ---
+++
@@ -3,7 +3,7 @@
import logging
if not os.path.exists(os.path.expanduser("~/.chatserver")):
- os.makedirs(os.path.expanduser("~/.chatserver")
+ os.makedirs(os.path.expanduser("~/.chatserver"))
logging.basicConfig(filename=os.path.expanduser("~/.chatserver/chat.log"), level=logging.DEBUG)
from app... |
7755ab25249c39350004447daa614bc35e4517e7 | src/malibu/__init__.py | src/malibu/__init__.py | # -*- coding: utf-8 -*-
from malibu import command # noqa
from malibu import config # noqa
from malibu import database # noqa
from malibu import design # noqa
from malibu import text # noqa
from malibu import util # noqa
import subprocess
__git_label__ = ''
try:
__git_label__ = subprocess.check_output(
... | # -*- coding: utf-8 -*-
from malibu import command # noqa
from malibu import config # noqa
from malibu import database # noqa
from malibu import design # noqa
from malibu import text # noqa
from malibu import util # noqa
import subprocess
__git_label__ = ''
try:
__git_label__ = subprocess.check_output(
... | Remove unnecessary strip, add finally for release tagger | 0.1.8: Remove unnecessary strip, add finally for release tagger
| Python | unlicense | maiome-development/malibu | ---
+++
@@ -19,9 +19,11 @@
])
except (subprocess.CalledProcessError, IOError):
__git_label__ = 'RELEASE'
+finally:
+ __git_label__ = __git_label__.decode('utf-8').strip()
__version__ = '0.1.8-7'
-__release__ = '{}-{}'.format(__version__, __git_label__).strip('\n')
+__release__ = '{}-{}'.format(__... |
44e5d35b6d43a22a480000b39a4e85335a27904b | corehq/apps/es/management/commands/wipe_es.py | corehq/apps/es/management/commands/wipe_es.py | from django.core.management import BaseCommand
from corehq.apps.cleanup.utils import confirm_destructive_operation
from corehq.elastic import get_es_new
class Command(BaseCommand):
"""
Wipe all data from BlobDB.
"""
def add_arguments(self, parser):
parser.add_argument(
'--commit',... | from django.core.management import BaseCommand
from corehq.apps.cleanup.utils import confirm_destructive_operation
from corehq.elastic import get_es_new
from corehq.util.es.elasticsearch import IndicesClient
class Command(BaseCommand):
"""
Wipe all data from BlobDB.
"""
def add_arguments(self, parser... | Use IndicesClient to get full URL | Use IndicesClient to get full URL
| Python | bsd-3-clause | dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq,dimagi/commcare-hq | ---
+++
@@ -2,6 +2,7 @@
from corehq.apps.cleanup.utils import confirm_destructive_operation
from corehq.elastic import get_es_new
+from corehq.util.es.elasticsearch import IndicesClient
class Command(BaseCommand):
@@ -34,5 +35,6 @@
$ curl -X DELETE "$PROTO://$HOSTNAME:$PORT/_all"
"""
es = ... |
a4bc21a1e24b0ac86564b1259a2583ed680a29e2 | aque/handlers/reduce.py | aque/handlers/reduce.py | import logging
from aque.utils import decode_callable
log = logging.getLogger(__name__)
def reduce_children(job):
func = decode_callable(job.get('func'))
sequence = [child.result() for child in job.children()]
try:
args = (job['initial'], )
except:
args = ()
log.debug('reducin... | import logging
from aque.utils import decode_callable
log = logging.getLogger(__name__)
def reduce_children(job):
func = decode_callable(job.get('func'))
args = job.get('args', ())
if len(args) >= 2:
job.error('too many args; reduce expects 1, got %d' % len(args))
return
sequence... | Reduce pulls initial from args | Reduce pulls initial from args
| Python | bsd-3-clause | mikeboers/aque,mikeboers/aque | ---
+++
@@ -9,11 +9,13 @@
def reduce_children(job):
func = decode_callable(job.get('func'))
+
+ args = job.get('args', ())
+ if len(args) >= 2:
+ job.error('too many args; reduce expects 1, got %d' % len(args))
+ return
+
sequence = [child.result() for child in job.children()]
- tr... |
a6be362f03410b53cd21d6ff7b63bdaef6963ad4 | findingaids/__init__.py | findingaids/__init__.py | # file findingaids/__init__.py
#
# Copyright 2012 Emory University Library
#
# 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
#
# U... | # file findingaids/__init__.py
#
# Copyright 2012 Emory University Library
#
# 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
#
# U... | Update dev version to 1.10 | Update dev version to 1.10
| Python | apache-2.0 | emory-libraries/findingaids,emory-libraries/findingaids | ---
+++
@@ -14,7 +14,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.
-__version_info__ = (1, 9, 0, None)
+__version_info__ = (1, 10, 0, 'dev')
# Dot-connect all but the last. Last is dash-connected if not None.
__version__ = '.'.join(str(i) for i... |
4a69aa350f0b3cf95cbf2f518d58310be5731a74 | salt/pwm-server/config.py | salt/pwm-server/config.py | SQLALCHEMY_DATABASE_URI = 'sqlite:///srv/pwm-server/db.sqlite'
| SQLALCHEMY_DATABASE_URI = 'sqlite:////srv/pwm-server/db.sqlite'
| Correct the path to the sqlite db on vagrant | Correct the path to the sqlite db on vagrant
| Python | mit | thusoy/pwm-server,thusoy/pwm-server | ---
+++
@@ -1 +1 @@
-SQLALCHEMY_DATABASE_URI = 'sqlite:///srv/pwm-server/db.sqlite'
+SQLALCHEMY_DATABASE_URI = 'sqlite:////srv/pwm-server/db.sqlite' |
a8b1b4ca3fd4964b2349ed085e8d2350072e67b9 | d1_libclient_python/src/d1_client/__init__.py | d1_libclient_python/src/d1_client/__init__.py | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This work was created by participants in the DataONE project, and is
# jointly copyrighted by participating institutions in DataONE. For
# more information on DataONE, see our web site at http://dataone.org.
#
# Copyright 2009-2012 DataONE
#
# Licensed under the Apache... | #!/usr/bin/env python
# -*- coding: utf-8 -*-
# This work was created by participants in the DataONE project, and is
# jointly copyrighted by participating institutions in DataONE. For
# more information on DataONE, see our web site at http://dataone.org.
#
# Copyright 2009-2012 DataONE
#
# Licensed under the Apache... | Remove implicit import of symbols | Remove implicit import of symbols
Currently, using libclient for python requires selecting the target node type (MN or CN) and the target DataONE API version, by specifying the appropriate client, so it better to use the library by explicitly importing only the needed clients instead of all of of them.
| Python | apache-2.0 | DataONEorg/d1_python,DataONEorg/d1_python,DataONEorg/d1_python,DataONEorg/d1_python | ---
+++
@@ -21,20 +21,20 @@
__version__ = "2.0.dev8"
-__all__ = [
- 'cnclient',
- 'cnclient_1_1',
- 'd1baseclient',
- 'd1baseclient_1_1',
- 'd1baseclient_2_0',
- 'd1client',
- 'data_package',
- 'logrecorditerator',
- 'mnclient',
- 'mnclient_1_1',
- 'object_format_info',
- 'objectlistiterator',
- 'so... |
1ebf1cfb0ca67d7bb10fa776b5944d8755292999 | shellstreaming/test/inputstream/test_textfile.py | shellstreaming/test/inputstream/test_textfile.py | # -*- coding: utf-8 -*-
from nose.tools import *
import os
import time
from shellstreaming.inputstream.textfile import TextFile
TEST_FILE = os.path.abspath(os.path.dirname(__file__)) + '/test_textfile_input01.txt'
def test_textfile_usage():
n_batches = n_records = 0
stream = TextFile(TEST_FILE, batch_span_m... | # -*- coding: utf-8 -*-
from nose.tools import *
import time
from os.path import abspath, dirname, join
from shellstreaming.inputstream.textfile import TextFile
TEST_FILE = join(abspath(dirname(__file__)), 'test_textfile_input01.txt')
def test_textfile_usage():
n_batches = n_records = 0
stream = TextFile(TE... | Use os.path.join instead of string concatenation. | Use os.path.join instead of string concatenation.
Use `join` in order to create path intelligently on all operating
systems. See: http://docs.python.org/2/library/os.path.html#os.path.join
| Python | apache-2.0 | laysakura/shellstreaming,laysakura/shellstreaming | ---
+++
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from nose.tools import *
-import os
import time
+from os.path import abspath, dirname, join
from shellstreaming.inputstream.textfile import TextFile
-TEST_FILE = os.path.abspath(os.path.dirname(__file__)) + '/test_textfile_input01.txt'
+TEST_FILE = join(abspat... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.