commit stringlengths 40 40 | old_file stringlengths 4 118 | new_file stringlengths 4 118 | old_contents stringlengths 10 2.94k | new_contents stringlengths 21 3.18k | subject stringlengths 16 444 | message stringlengths 17 2.63k | lang stringclasses 1
value | license stringclasses 13
values | repos stringlengths 5 43k | ndiff stringlengths 52 3.32k | instruction stringlengths 16 444 | content stringlengths 133 4.32k | fuzzy_diff stringlengths 16 3.18k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
2a0a29effa48caf5d95ed892d85cee235ebe1624 | lamvery/utils.py | lamvery/utils.py |
import os
import sys
import re
import shlex
import subprocess
from termcolor import cprint
ENV_PATTERN = re.compile('^(?P<name>[^\s]+)\s*=\s*(?P<value>.+)$')
def previous_alias(alias):
return '{}-pre'.format(alias)
def parse_env_args(env):
if not isinstance(env, list):
return None
ret = {}
... |
import os
import sys
import re
import shlex
import subprocess
ENV_PATTERN = re.compile('^(?P<name>[^\s]+)\s*=\s*(?P<value>.+)$')
def previous_alias(alias):
return '{}-pre'.format(alias)
def parse_env_args(env):
if not isinstance(env, list):
return None
ret = {}
for e in env:
match... | Fix error when import lamvery in function | Fix error when import lamvery in function
| Python | mit | marcy-terui/lamvery,marcy-terui/lamvery |
import os
import sys
import re
import shlex
import subprocess
- from termcolor import cprint
ENV_PATTERN = re.compile('^(?P<name>[^\s]+)\s*=\s*(?P<value>.+)$')
def previous_alias(alias):
return '{}-pre'.format(alias)
def parse_env_args(env):
if not isinstance(env, list):
... | Fix error when import lamvery in function | ## Code Before:
import os
import sys
import re
import shlex
import subprocess
from termcolor import cprint
ENV_PATTERN = re.compile('^(?P<name>[^\s]+)\s*=\s*(?P<value>.+)$')
def previous_alias(alias):
return '{}-pre'.format(alias)
def parse_env_args(env):
if not isinstance(env, list):
return None
... | ...
import subprocess
...
if os.path.exists(path):
print('Overwrite {}? [y/n]: '.format(path))
y_n = sys.stdin.readline()
... |
293d50438fab81e74ab4559df7a4f7aa7cfd8f03 | etcdocker/container.py | etcdocker/container.py | import docker
from etcdocker import util
class Container:
def __init__(self, name, params):
self.name = name
self.params = params
def set_or_create_param(self, key, value):
self.params[key] = value
def ensure_running(self, force_restart=False):
# Ensure container is runn... | import ast
import docker
from etcdocker import util
class Container:
def __init__(self, name, params):
self.name = name
self.params = params
def set_or_create_param(self, key, value):
self.params[key] = value
def ensure_running(self, force_restart=False):
# Ensure contai... | Convert port list to dict | Convert port list to dict
| Python | mit | CloudBrewery/docrane | + import ast
import docker
from etcdocker import util
class Container:
def __init__(self, name, params):
self.name = name
self.params = params
def set_or_create_param(self, key, value):
self.params[key] = value
def ensure_running(self, force_restart=F... | Convert port list to dict | ## Code Before:
import docker
from etcdocker import util
class Container:
def __init__(self, name, params):
self.name = name
self.params = params
def set_or_create_param(self, key, value):
self.params[key] = value
def ensure_running(self, force_restart=False):
# Ensure c... | // ... existing code ...
import ast
import docker
// ... modified code ...
# Convert our ports into a dict if necessary
ports = ast.literal_eval(self.params.get('ports'))
# Create container with specified args
...
volumes=self.params.get('volumes'),
ports=... |
6d72a1d3b4bd2e1a11e2fb9744353e5d2d9c8863 | setup.py | setup.py | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("lulu_base", ["lulu_base.pyx"]),
Extension("ccomp", ["ccomp.pyx"])])
| from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
import numpy
def cext(name):
return Extension(name, [name + ".pyx"],
include_dirs=[numpy.get_include()])
setup(cmdclass = {'build_ext': build_ext},
ext_modules = [cext('lulu... | Add NumPy includes dir for Cython builds. | Add NumPy includes dir for Cython builds.
| Python | bsd-3-clause | stefanv/lulu | from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
+ import numpy
+
+ def cext(name):
+ return Extension(name, [name + ".pyx"],
+ include_dirs=[numpy.get_include()])
setup(cmdclass = {'build_ext': build_ext},
+ ext... | Add NumPy includes dir for Cython builds. | ## Code Before:
from distutils.core import setup
from distutils.extension import Extension
from Cython.Distutils import build_ext
setup(cmdclass = {'build_ext': build_ext},
ext_modules = [Extension("lulu_base", ["lulu_base.pyx"]),
Extension("ccomp", ["ccomp.pyx"])])
## Instruction:
Add NumP... | ...
from Cython.Distutils import build_ext
import numpy
def cext(name):
return Extension(name, [name + ".pyx"],
include_dirs=[numpy.get_include()])
...
setup(cmdclass = {'build_ext': build_ext},
ext_modules = [cext('lulu_base'), cext('ccomp')])
... |
14a085f787f5fe80a0737d97515b71adaf05d1cd | checker/checker/contest.py | checker/checker/contest.py |
from checker.abstract import AbstractChecker
import base64
import sys
import codecs
class ContestChecker(AbstractChecker):
def __init__(self, tick, team, service, ip):
AbstractChecker.__init__(self, tick, team, service, ip)
def _rpc(self, function, *args):
sys.stdout.write("%s %s\n" % (funct... |
from checker.abstract import AbstractChecker
import base64
import sys
import codecs
class ContestChecker(AbstractChecker):
def __init__(self, tick, team, service, ip):
AbstractChecker.__init__(self, tick, team, service, ip)
def _rpc(self, function, *args):
sys.stdout.write("%s %s\n" % (funct... | Fix double-encoding of binary blobs | Fix double-encoding of binary blobs
| Python | isc | fausecteam/ctf-gameserver,fausecteam/ctf-gameserver,fausecteam/ctf-gameserver,fausecteam/ctf-gameserver,fausecteam/ctf-gameserver |
from checker.abstract import AbstractChecker
import base64
import sys
import codecs
class ContestChecker(AbstractChecker):
def __init__(self, tick, team, service, ip):
AbstractChecker.__init__(self, tick, team, service, ip)
def _rpc(self, function, *args):
sys.stdou... | Fix double-encoding of binary blobs | ## Code Before:
from checker.abstract import AbstractChecker
import base64
import sys
import codecs
class ContestChecker(AbstractChecker):
def __init__(self, tick, team, service, ip):
AbstractChecker.__init__(self, tick, team, service, ip)
def _rpc(self, function, *args):
sys.stdout.write("%... | # ... existing code ...
data = base64.b64encode(blob)
return self._rpc("STORE", ident, data.decode('latin-1'))
# ... rest of the code ... |
e50aee5973a2593546d1308b5ba77cd0905dd2be | app/models.py | app/models.py |
import dataclasses
from ntuweather import Weather
from sqlalchemy import Table, Column, DateTime, Integer, Float
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class WeatherData(Base):
"""Represents a weather record saved in the database."""
__tablename__ = 'weather_data'
... |
import dataclasses
from ntuweather import Weather
from sqlalchemy import Table, Column, DateTime, Integer, Float
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class WeatherData(Base):
"""Represents a weather record saved in the database."""
__tablename__ = 'weather_data'
... | Fix excessive fields in conversion | Fix excessive fields in conversion
| Python | agpl-3.0 | rschiang/ntu-weather,rschiang/ntu-weather |
import dataclasses
from ntuweather import Weather
from sqlalchemy import Table, Column, DateTime, Integer, Float
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class WeatherData(Base):
"""Represents a weather record saved in the database."""
__table... | Fix excessive fields in conversion | ## Code Before:
import dataclasses
from ntuweather import Weather
from sqlalchemy import Table, Column, DateTime, Integer, Float
from sqlalchemy.ext.declarative import declarative_base
Base = declarative_base()
class WeatherData(Base):
"""Represents a weather record saved in the database."""
__tablename__ =... | # ... existing code ...
del fields['provider'] # We don’t store provider name as there would be only one.
del fields['valid'] # We only store valid weather data, hence.
return cls(**fields)
# ... rest of the code ... |
da59d4334eb1a6f77bd0a9599614a6289ef843e4 | pytest-server-fixtures/tests/integration/test_mongo_server.py | pytest-server-fixtures/tests/integration/test_mongo_server.py | import pytest
def test_mongo_server(mongo_server):
assert mongo_server.check_server_up()
assert mongo_server.delete
mongo_server.api.db.test.insert_one({'a': 'b', 'c': 'd'})
assert mongo_server.api.db.test.find_one({'a': 'b'}, {'_id': False}) == {'a': 'b', 'c': 'd'}
@pytest.mark.parametrize('count',... | import pytest
def test_mongo_server(mongo_server):
assert mongo_server.check_server_up()
assert mongo_server.delete
mongo_server.api.db.test.insert({'a': 'b', 'c': 'd'})
assert mongo_server.api.db.test.find_one({'a': 'b'}, {'_id': False}) == {'a': 'b', 'c': 'd'}
@pytest.mark.parametrize('count', ran... | Revert "fix deprecation warnings in mongo" | Revert "fix deprecation warnings in mongo"
This reverts commit 5d449ff9376e7c0a3c78f2b2d631ab0ecd08fe81.
| Python | mit | manahl/pytest-plugins,manahl/pytest-plugins | import pytest
def test_mongo_server(mongo_server):
assert mongo_server.check_server_up()
assert mongo_server.delete
- mongo_server.api.db.test.insert_one({'a': 'b', 'c': 'd'})
+ mongo_server.api.db.test.insert({'a': 'b', 'c': 'd'})
assert mongo_server.api.db.test.find_one({'a': 'b'},... | Revert "fix deprecation warnings in mongo" | ## Code Before:
import pytest
def test_mongo_server(mongo_server):
assert mongo_server.check_server_up()
assert mongo_server.delete
mongo_server.api.db.test.insert_one({'a': 'b', 'c': 'd'})
assert mongo_server.api.db.test.find_one({'a': 'b'}, {'_id': False}) == {'a': 'b', 'c': 'd'}
@pytest.mark.para... | # ... existing code ...
assert mongo_server.delete
mongo_server.api.db.test.insert({'a': 'b', 'c': 'd'})
assert mongo_server.api.db.test.find_one({'a': 'b'}, {'_id': False}) == {'a': 'b', 'c': 'd'}
# ... modified code ...
coll = mongo_server.api.some_database.some_collection
assert coll.coun... |
a1bcb99691f5a0238f6a34a5579df3e89e8d6823 | child_sync_gp/model/project_compassion.py | child_sync_gp/model/project_compassion.py |
from openerp.osv import orm
from . import gp_connector
class project_compassion(orm.Model):
_inherit = 'compassion.project'
def write(self, cr, uid, ids, vals, context=None):
"""Update Project in GP."""
res = super(project_compassion, self).write(cr, uid, ids, vals,
... |
from openerp.osv import orm
from . import gp_connector
class project_compassion(orm.Model):
_inherit = 'compassion.project'
def write(self, cr, uid, ids, vals, context=None):
"""Update Project in GP."""
res = super(project_compassion, self).write(cr, uid, ids, vals,
... | Fix bug in write project. | Fix bug in write project.
| Python | agpl-3.0 | CompassionCH/compassion-switzerland,ndtran/compassion-switzerland,MickSandoz/compassion-switzerland,eicher31/compassion-switzerland,Secheron/compassion-switzerland,CompassionCH/compassion-switzerland,Secheron/compassion-switzerland,CompassionCH/compassion-switzerland,MickSandoz/compassion-switzerland,ecino/compassion-s... |
from openerp.osv import orm
from . import gp_connector
class project_compassion(orm.Model):
_inherit = 'compassion.project'
def write(self, cr, uid, ids, vals, context=None):
"""Update Project in GP."""
res = super(project_compassion, self).write(cr, uid, ... | Fix bug in write project. | ## Code Before:
from openerp.osv import orm
from . import gp_connector
class project_compassion(orm.Model):
_inherit = 'compassion.project'
def write(self, cr, uid, ids, vals, context=None):
"""Update Project in GP."""
res = super(project_compassion, self).write(cr, uid, ids, vals,
... | # ... existing code ...
context)
if not isinstance(ids, list):
ids = [ids]
gp_connect = gp_connector.GPConnect()
# ... rest of the code ... |
8235a217b50520093d549115fe09a8d4ff5e9191 | webmanager/default_settings.py | webmanager/default_settings.py | INSTALLED_APPS += (
'simplemenu',
'webmanager',
'bootstrapform',
'userenabootstrap',
'userena',
# 'social_auth',
'provider.oauth2',
)
TEMPLATE_CONTEXT_PROCESSORS += (
'django.contrib.auth.context_processors.auth',
)
AUTHENTICATION_BACKENDS += (
'userena.backends.UserenaAuthenticati... | INSTALLED_APPS += (
'provider',
'provider.oauth2',
'simplemenu',
'webmanager',
'bootstrapform',
'userenabootstrap',
'userena',
# 'social_auth',
)
TEMPLATE_CONTEXT_PROCESSORS += (
'django.contrib.auth.context_processors.auth',
)
AUTHENTICATION_BACKENDS += (
'userena.backends.Use... | Fix provider oauth2 warning by import provider before oauth2 as described in the manual | Fix provider oauth2 warning by import provider before oauth2 as described in the manual
| Python | bsd-3-clause | weijia/webmanager,weijia/webmanager,weijia/webmanager | INSTALLED_APPS += (
+ 'provider',
+ 'provider.oauth2',
'simplemenu',
'webmanager',
'bootstrapform',
'userenabootstrap',
'userena',
# 'social_auth',
- 'provider.oauth2',
)
TEMPLATE_CONTEXT_PROCESSORS += (
'django.contrib.auth.context_processors.auth',
)
... | Fix provider oauth2 warning by import provider before oauth2 as described in the manual | ## Code Before:
INSTALLED_APPS += (
'simplemenu',
'webmanager',
'bootstrapform',
'userenabootstrap',
'userena',
# 'social_auth',
'provider.oauth2',
)
TEMPLATE_CONTEXT_PROCESSORS += (
'django.contrib.auth.context_processors.auth',
)
AUTHENTICATION_BACKENDS += (
'userena.backends.Use... | ...
INSTALLED_APPS += (
'provider',
'provider.oauth2',
'simplemenu',
...
# 'social_auth',
)
... |
3fbca600b1b90ad3499d941e178aae89d1c7df70 | regulations/generator/layers/external_citation.py | regulations/generator/layers/external_citation.py | from django.template import loader
import utils
from regulations.generator.layers.base import SearchReplaceLayer
class ExternalCitationLayer(SearchReplaceLayer):
shorthand = 'external'
data_source = 'external-citations'
def __init__(self, layer):
self.layer = layer
self.template = loader... | from django.template import loader
from regulations.generator.layers import utils
from regulations.generator.layers.base import SearchReplaceLayer
class ExternalCitationLayer(SearchReplaceLayer):
shorthand = 'external'
data_source = 'external-citations'
def __init__(self, layer):
self.layer = la... | Make external citations Python3 compatible | Make external citations Python3 compatible
| Python | cc0-1.0 | 18F/regulations-site,18F/regulations-site,tadhg-ohiggins/regulations-site,eregs/regulations-site,18F/regulations-site,tadhg-ohiggins/regulations-site,eregs/regulations-site,tadhg-ohiggins/regulations-site,eregs/regulations-site,18F/regulations-site,tadhg-ohiggins/regulations-site,eregs/regulations-site | from django.template import loader
- import utils
+ from regulations.generator.layers import utils
from regulations.generator.layers.base import SearchReplaceLayer
class ExternalCitationLayer(SearchReplaceLayer):
shorthand = 'external'
data_source = 'external-citations'
def __init__(... | Make external citations Python3 compatible | ## Code Before:
from django.template import loader
import utils
from regulations.generator.layers.base import SearchReplaceLayer
class ExternalCitationLayer(SearchReplaceLayer):
shorthand = 'external'
data_source = 'external-citations'
def __init__(self, layer):
self.layer = layer
self.t... | # ... existing code ...
from django.template import loader
from regulations.generator.layers import utils
from regulations.generator.layers.base import SearchReplaceLayer
# ... rest of the code ... |
30f8317838a2e984e54fe22042fd3ffff10f82e6 | waterbutler/core/streams/file.py | waterbutler/core/streams/file.py | import os
import asyncio
from waterbutler.core.streams import BaseStream
class FileStreamReader(BaseStream):
def __init__(self, file_pointer):
super().__init__()
self.file_gen = None
self.file_pointer = file_pointer
self.read_size = None
self.content_type = 'application/o... | import os
from waterbutler.core.streams import BaseStream
class FileStreamReader(BaseStream):
def __init__(self, file_pointer):
super().__init__()
self.file_gen = None
self.file_pointer = file_pointer
self.read_size = None
self.content_type = 'application/octet-stream'
... | Update FileStreamReader for new python 3.5 async | Update FileStreamReader for new python 3.5 async
| Python | apache-2.0 | RCOSDP/waterbutler,felliott/waterbutler,rdhyee/waterbutler,CenterForOpenScience/waterbutler,TomBaxter/waterbutler,Johnetordoff/waterbutler | import os
- import asyncio
from waterbutler.core.streams import BaseStream
class FileStreamReader(BaseStream):
def __init__(self, file_pointer):
super().__init__()
self.file_gen = None
self.file_pointer = file_pointer
self.read_size = None
self.c... | Update FileStreamReader for new python 3.5 async | ## Code Before:
import os
import asyncio
from waterbutler.core.streams import BaseStream
class FileStreamReader(BaseStream):
def __init__(self, file_pointer):
super().__init__()
self.file_gen = None
self.file_pointer = file_pointer
self.read_size = None
self.content_type ... | // ... existing code ...
import os
// ... modified code ...
while True:
chunk = self.file_pointer.read(self.read_size)
if not chunk:
self.feed_eof()
chunk = b''
yield chunk
...
self.file_gen = self.file_gen or self.read_... |
30044f8272557dbd367eab3dbe7c1ba1076484e9 | readux/pages/models.py | readux/pages/models.py | from django.db import models
# Create your models here.
from django.utils.translation import ugettext_lazy as _
from feincms.module.page.models import Page
from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.models import MediaFileContent
# Page.register_extensions('datepub... | from django.db import models
# Create your models here.
from django.utils.translation import ugettext_lazy as _
from feincms.module.page.models import Page
from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.models import MediaFileContent
from feincms.content.video.models im... | Enable video content for cms pages | Enable video content for cms pages
[#110289088]
| Python | apache-2.0 | emory-libraries/readux,emory-libraries/readux,emory-libraries/readux | from django.db import models
# Create your models here.
from django.utils.translation import ugettext_lazy as _
from feincms.module.page.models import Page
from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.models import MediaFileContent
+ from feincms.con... | Enable video content for cms pages | ## Code Before:
from django.db import models
# Create your models here.
from django.utils.translation import ugettext_lazy as _
from feincms.module.page.models import Page
from feincms.content.richtext.models import RichTextContent
from feincms.content.medialibrary.models import MediaFileContent
# Page.register_ext... | // ... existing code ...
from feincms.content.medialibrary.models import MediaFileContent
from feincms.content.video.models import VideoContent
// ... modified code ...
))
Page.create_content_type(VideoContent)
// ... rest of the code ... |
65e6c8466482464333e77a2892fd0ac33ab5c3cb | q_and_a/apps/token_auth/views.py | q_and_a/apps/token_auth/views.py | from django.views.generic import RedirectView
from django.views.generic.detail import SingleObjectMixin
from django.contrib.auth import login, authenticate, login
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
class BaseAuthView(SingleObjectMixin, RedirectView):
d... | from django.views.generic import RedirectView
from django.views.generic.detail import SingleObjectMixin
from django.contrib.auth import login, authenticate
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
class BaseAuthView(SingleObjectMixin, RedirectView):
def get_... | Fix indent, PEP-8 style and remove dup import. | Fix indent, PEP-8 style and remove dup import.
| Python | bsd-3-clause | DemocracyClub/candidate_questions,DemocracyClub/candidate_questions,DemocracyClub/candidate_questions | from django.views.generic import RedirectView
from django.views.generic.detail import SingleObjectMixin
- from django.contrib.auth import login, authenticate, login
+ from django.contrib.auth import login, authenticate
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reve... | Fix indent, PEP-8 style and remove dup import. | ## Code Before:
from django.views.generic import RedirectView
from django.views.generic.detail import SingleObjectMixin
from django.contrib.auth import login, authenticate, login
from django.core.exceptions import PermissionDenied
from django.core.urlresolvers import reverse
class BaseAuthView(SingleObjectMixin, Redir... | // ... existing code ...
from django.views.generic.detail import SingleObjectMixin
from django.contrib.auth import login, authenticate
from django.core.exceptions import PermissionDenied
// ... modified code ...
def get_redirect_url(self, *args, **kwargs):
if (not self.request.user.is_authenticated(... |
b4d9fb47e040b199f88cffb4a0b761c443f390b4 | dduplicated/cli.py | dduplicated/cli.py | from os import path as opath, getcwd
from pprint import pprint
from sys import argv
from dduplicated import commands
def get_paths(params):
paths = []
for param in params:
path = opath.join(getcwd(), param)
if opath.exists(path) and opath.isdir(path) and not opath.islink(path):
paths.append(path)
return pat... | from os import path as opath, getcwd
from pprint import pprint
from sys import argv
from dduplicated import commands
def get_paths(params):
paths = []
for param in params:
path = opath.join(getcwd(), param)
if opath.exists(path) and opath.isdir(path) and not opath.islink(path):
paths.append(path)
return pa... | Update in output to terminal. | Update in output to terminal.
Signed-off-by: messiasthi <8562fc1efba9a3c99753c749fdfb1b6932b70fbf@gmail.com>
| Python | mit | messiasthi/dduplicated-cli | from os import path as opath, getcwd
from pprint import pprint
from sys import argv
+
from dduplicated import commands
def get_paths(params):
paths = []
for param in params:
path = opath.join(getcwd(), param)
if opath.exists(path) and opath.isdir(path) and not opath.islink(path):
paths.... | Update in output to terminal. | ## Code Before:
from os import path as opath, getcwd
from pprint import pprint
from sys import argv
from dduplicated import commands
def get_paths(params):
paths = []
for param in params:
path = opath.join(getcwd(), param)
if opath.exists(path) and opath.isdir(path) and not opath.islink(path):
paths.append(pa... | ...
from sys import argv
from dduplicated import commands
...
commands.help()
exit()
... |
536211012be24a20c34ef0af1fcc555672129354 | byceps/util/system.py | byceps/util/system.py |
import os
CONFIG_ENV_VAR_NAME = 'BYCEPS_CONFIG'
def get_config_env_name_from_env(*, default=None):
"""Return the configuration environment name set via environment
variable.
Raise an exception if it isn't set.
"""
env = os.environ.get(CONFIG_ENV_VAR_NAME)
if env is None:
if defaul... |
import os
CONFIG_ENV_VAR_NAME = 'BYCEPS_CONFIG'
def get_config_env_name_from_env():
"""Return the configuration environment name set via environment
variable.
Raise an exception if it isn't set.
"""
env = os.environ.get(CONFIG_ENV_VAR_NAME)
if not env:
raise Exception(
... | Remove default argument from function that reads the configuration name from the environment | Remove default argument from function that reads the configuration name from the environment
| Python | bsd-3-clause | homeworkprod/byceps,m-ober/byceps,m-ober/byceps,m-ober/byceps,homeworkprod/byceps,homeworkprod/byceps |
import os
CONFIG_ENV_VAR_NAME = 'BYCEPS_CONFIG'
- def get_config_env_name_from_env(*, default=None):
+ def get_config_env_name_from_env():
"""Return the configuration environment name set via environment
variable.
Raise an exception if it isn't set.
"""
env = os.envir... | Remove default argument from function that reads the configuration name from the environment | ## Code Before:
import os
CONFIG_ENV_VAR_NAME = 'BYCEPS_CONFIG'
def get_config_env_name_from_env(*, default=None):
"""Return the configuration environment name set via environment
variable.
Raise an exception if it isn't set.
"""
env = os.environ.get(CONFIG_ENV_VAR_NAME)
if env is None:
... | // ... existing code ...
def get_config_env_name_from_env():
"""Return the configuration environment name set via environment
// ... modified code ...
if not env:
raise Exception(
"No configuration environment was specified via the '{}' "
"environment variable.".format(... |
a8a56f20dd76f61ec1ea6e99037490922d5cbcb1 | setup.py | setup.py |
from distutils.core import setup
setup(
name='grammpy',
version='1.1.1',
packages=['grammpy', 'grammpy.Grammars', 'grammpy.exceptions'],
url='https://github.com/PatrikValkovic/grammpy',
license='GNU General Public License v3.0',
author='Patrik Valkovic',
download_url='https://github.com/P... |
from distutils.core import setup
setup(
name='grammpy',
version='1.1.1',
packages=['grammpy', 'grammpy.Grammars', 'grammpy.exceptions', 'grammpy.Rules'],
url='https://github.com/PatrikValkovic/grammpy',
license='GNU General Public License v3.0',
author='Patrik Valkovic',
download_url='htt... | FIX missing Rules directory in package | FIX missing Rules directory in package
| Python | mit | PatrikValkovic/grammpy |
from distutils.core import setup
setup(
name='grammpy',
version='1.1.1',
- packages=['grammpy', 'grammpy.Grammars', 'grammpy.exceptions'],
+ packages=['grammpy', 'grammpy.Grammars', 'grammpy.exceptions', 'grammpy.Rules'],
url='https://github.com/PatrikValkovic/grammpy',
lice... | FIX missing Rules directory in package | ## Code Before:
from distutils.core import setup
setup(
name='grammpy',
version='1.1.1',
packages=['grammpy', 'grammpy.Grammars', 'grammpy.exceptions'],
url='https://github.com/PatrikValkovic/grammpy',
license='GNU General Public License v3.0',
author='Patrik Valkovic',
download_url='http... | ...
version='1.1.1',
packages=['grammpy', 'grammpy.Grammars', 'grammpy.exceptions', 'grammpy.Rules'],
url='https://github.com/PatrikValkovic/grammpy',
... |
6c564ebe538d2723cc5f9397e09e5945796a257e | pyelevator/message.py | pyelevator/message.py | import msgpack
import logging
from .constants import FAILURE_STATUS
class MessageFormatError(Exception):
pass
class Request(object):
"""Handler objects for frontend->backend objects messages"""
def __new__(cls, *args, **kwargs):
content = {
'DB_UID': kwargs.pop('db_uid'),
... | import msgpack
import logging
from .constants import FAILURE_STATUS
class MessageFormatError(Exception):
pass
class Request(object):
"""Handler objects for frontend->backend objects messages"""
def __new__(cls, *args, **kwargs):
content = {
'DB_UID': kwargs.pop('db_uid'),
... | Fix : Range of len(1) have to be a tuple of tuples | Fix : Range of len(1) have to be a tuple of tuples
| Python | mit | oleiade/py-elevator | import msgpack
import logging
from .constants import FAILURE_STATUS
class MessageFormatError(Exception):
pass
class Request(object):
"""Handler objects for frontend->backend objects messages"""
def __new__(cls, *args, **kwargs):
content = {
'DB_UID': kw... | Fix : Range of len(1) have to be a tuple of tuples | ## Code Before:
import msgpack
import logging
from .constants import FAILURE_STATUS
class MessageFormatError(Exception):
pass
class Request(object):
"""Handler objects for frontend->backend objects messages"""
def __new__(cls, *args, **kwargs):
content = {
'DB_UID': kwargs.pop('db_u... | // ... existing code ...
if hasattr(self, '_datas') and self._datas is not None:
if (len(self._datas) == 1) and not isinstance(self._datas[0], (tuple, list)):
return self._datas[0]
// ... rest of the code ... |
464bc1b511415459e99700b94101776d00b23796 | indra/pre_assemble_for_db/pre_assemble_script.py | indra/pre_assemble_for_db/pre_assemble_script.py | import indra.tools.assemble_corpus as ac
def process_statements(stmts):
stmts = ac.map_grounding(stmts)
stmts = ac.map_sequence(stmts)
stmts = ac.run_preassembly(stmts, return_toplevel=False)
return stmts
| import indra.tools.assemble_corpus as ac
from indra.db.util import get_statements, insert_pa_stmts
def process_statements(stmts, num_procs=1):
stmts = ac.map_grounding(stmts)
stmts = ac.map_sequence(stmts)
stmts = ac.run_preassembly(stmts, return_toplevel=False,
poolsize=num... | Create function to handle full pipeline. | Create function to handle full pipeline.
| Python | bsd-2-clause | bgyori/indra,johnbachman/indra,bgyori/indra,sorgerlab/belpy,pvtodorov/indra,johnbachman/indra,sorgerlab/indra,bgyori/indra,johnbachman/belpy,pvtodorov/indra,sorgerlab/belpy,johnbachman/belpy,sorgerlab/indra,sorgerlab/belpy,johnbachman/indra,johnbachman/belpy,sorgerlab/indra,pvtodorov/indra,pvtodorov/indra | import indra.tools.assemble_corpus as ac
+ from indra.db.util import get_statements, insert_pa_stmts
+
- def process_statements(stmts):
+ def process_statements(stmts, num_procs=1):
stmts = ac.map_grounding(stmts)
stmts = ac.map_sequence(stmts)
- stmts = ac.run_preassembly(stmts, return_toplevel=F... | Create function to handle full pipeline. | ## Code Before:
import indra.tools.assemble_corpus as ac
def process_statements(stmts):
stmts = ac.map_grounding(stmts)
stmts = ac.map_sequence(stmts)
stmts = ac.run_preassembly(stmts, return_toplevel=False)
return stmts
## Instruction:
Create function to handle full pipeline.
## Code After:
import in... | // ... existing code ...
import indra.tools.assemble_corpus as ac
from indra.db.util import get_statements, insert_pa_stmts
def process_statements(stmts, num_procs=1):
stmts = ac.map_grounding(stmts)
// ... modified code ...
stmts = ac.map_sequence(stmts)
stmts = ac.run_preassembly(stmts, return_t... |
5b7a1a40ea43834feb5563f566d07bd5b31c589d | tests/test-recipes/metadata/always_include_files_glob/run_test.py | tests/test-recipes/metadata/always_include_files_glob/run_test.py | import os
import sys
import json
def main():
prefix = os.environ['PREFIX']
info_file = os.path.join(prefix, 'conda-meta',
'always_include_files_regex-0.1-0.json')
with open(info_file, 'r') as fh:
info = json.load(fh)
if sys.platform == 'darwin':
assert set... | import os
import sys
import json
def main():
prefix = os.environ['PREFIX']
info_file = os.path.join(prefix, 'conda-meta',
'always_include_files_regex-0.1-0.json')
with open(info_file, 'r') as fh:
info = json.load(fh)
if sys.platform == 'darwin':
assert set... | Add error messages to the asserts | Add error messages to the asserts
| Python | bsd-3-clause | ilastik/conda-build,shastings517/conda-build,frol/conda-build,dan-blanchard/conda-build,mwcraig/conda-build,mwcraig/conda-build,dan-blanchard/conda-build,ilastik/conda-build,sandhujasmine/conda-build,rmcgibbo/conda-build,sandhujasmine/conda-build,shastings517/conda-build,rmcgibbo/conda-build,shastings517/conda-build,da... | import os
import sys
import json
def main():
prefix = os.environ['PREFIX']
info_file = os.path.join(prefix, 'conda-meta',
'always_include_files_regex-0.1-0.json')
with open(info_file, 'r') as fh:
info = json.load(fh)
if sys.platform == 'd... | Add error messages to the asserts | ## Code Before:
import os
import sys
import json
def main():
prefix = os.environ['PREFIX']
info_file = os.path.join(prefix, 'conda-meta',
'always_include_files_regex-0.1-0.json')
with open(info_file, 'r') as fh:
info = json.load(fh)
if sys.platform == 'darwin':
... | ...
if sys.platform == 'darwin':
assert set(info['files']) == {'lib/libpng.dylib', 'lib/libpng16.16.dylib', 'lib/libpng16.dylib'}, info['files']
elif sys.platform.startswith('linux'):
assert set(info['files']) == {'lib/libpng.so', 'lib/libpng16.so', 'lib/libpng16.so.16', 'lib/libpng16.so.16.... |
114eae527cce97423ec5cc5896a4728dc0764d2c | chunsabot/modules/images.py | chunsabot/modules/images.py | import os
import json
import shutil
import subprocess
import string
import random
from chunsabot.database import Database
from chunsabot.botlogic import brain
RNN_PATH = Database.load_config('rnn_library_path')
MODEL_PATH = os.path.join(RNN_PATH, "models/checkpoint_v1.t7_cpu.t7")
def id_generator(size=12, chars=stri... | import os
import json
import shutil
import subprocess
import string
import random
from chunsabot.database import Database
from chunsabot.botlogic import brain
RNN_PATH = Database.load_config('rnn_library_path')
MODEL_PATH = os.path.join(RNN_PATH, "models/checkpoint_v1.t7_cpu.t7")
def id_generator(size=12, chars=stri... | Fix some confusion of creating folders | Fix some confusion of creating folders
| Python | mit | susemeee/Chunsabot-framework | import os
import json
import shutil
import subprocess
import string
import random
from chunsabot.database import Database
from chunsabot.botlogic import brain
RNN_PATH = Database.load_config('rnn_library_path')
MODEL_PATH = os.path.join(RNN_PATH, "models/checkpoint_v1.t7_cpu.t7")
def id_g... | Fix some confusion of creating folders | ## Code Before:
import os
import json
import shutil
import subprocess
import string
import random
from chunsabot.database import Database
from chunsabot.botlogic import brain
RNN_PATH = Database.load_config('rnn_library_path')
MODEL_PATH = os.path.join(RNN_PATH, "models/checkpoint_v1.t7_cpu.t7")
def id_generator(siz... | # ... existing code ...
path = os.path.join(brain.__temppath__, "{}_{}".format(id_generator(), 'image_processing'))
if not os.path.isdir(path):
# ... rest of the code ... |
c266fbd7a3478d582dc0d6c88fc5e3d8b7a8f62f | survey/views/survey_result.py | survey/views/survey_result.py |
import datetime
import os
from django.http.response import HttpResponse
from django.shortcuts import get_object_or_404
from survey.management.survey2csv import Survey2CSV
from survey.models import Survey
def serve_result_csv(request, pk):
survey = get_object_or_404(Survey, pk=pk)
try:
latest_answer... |
import datetime
import os
from django.http.response import HttpResponse
from django.shortcuts import get_object_or_404
from survey.management.survey2csv import Survey2CSV
from survey.models import Survey
def serve_result_csv(request, pk):
survey = get_object_or_404(Survey, pk=pk)
try:
latest_answer... | Fix - Apache error AH02429 | Fix - Apache error AH02429
Response header name 'mimetype=' contains invalid characters, aborting request
| Python | agpl-3.0 | Pierre-Sassoulas/django-survey,Pierre-Sassoulas/django-survey,Pierre-Sassoulas/django-survey |
import datetime
import os
from django.http.response import HttpResponse
from django.shortcuts import get_object_or_404
from survey.management.survey2csv import Survey2CSV
from survey.models import Survey
def serve_result_csv(request, pk):
survey = get_object_or_404(Survey, pk=pk)
... | Fix - Apache error AH02429 | ## Code Before:
import datetime
import os
from django.http.response import HttpResponse
from django.shortcuts import get_object_or_404
from survey.management.survey2csv import Survey2CSV
from survey.models import Survey
def serve_result_csv(request, pk):
survey = get_object_or_404(Survey, pk=pk)
try:
... | ...
response = HttpResponse(f.read(), content_type='text/csv')
cd = u'attachment; filename="{}.csv"'.format(survey.name)
... |
3a6d76201104b928c1b9053317c9e61804814ff5 | pyresticd.py | pyresticd.py |
import os
import getpass
import time
from twisted.internet import task
from twisted.internet import reactor
# Configuration
timeout = 3600*24*3 # Period
restic_command = "/home/mebus/restic" # your restic command here
# Program
def do_restic_backup():
print "\nStarting Backup at " + str(time.ctime())
os.... |
import os
import getpass
import time
from twisted.internet import task
from twisted.internet import reactor
# Configuration
timeout = 3600*24*3 # Period
restic_command = "/home/mebus/restic" # your restic command here
# Program
def do_restic_backup():
print('Starting Backup at {}'.format(time.ctime()))
o... | Use py3-style print and string-formatting | Use py3-style print and string-formatting
| Python | mit | Mebus/pyresticd,Mebus/pyresticd |
import os
import getpass
import time
from twisted.internet import task
from twisted.internet import reactor
- # Configuration
+ # Configuration
timeout = 3600*24*3 # Period
restic_command = "/home/mebus/restic" # your restic command here
# Program
+
def do_restic_backup():
- pr... | Use py3-style print and string-formatting | ## Code Before:
import os
import getpass
import time
from twisted.internet import task
from twisted.internet import reactor
# Configuration
timeout = 3600*24*3 # Period
restic_command = "/home/mebus/restic" # your restic command here
# Program
def do_restic_backup():
print "\nStarting Backup at " + str(time.... | # ... existing code ...
# Configuration
# ... modified code ...
def do_restic_backup():
print('Starting Backup at {}'.format(time.ctime()))
os.system(restic_command)
...
print('Restic Scheduler')
print('-' * 30)
print('Timeout: {}'.format(timeout))
restic_password = getpass.getpass(prompt="Pl... |
5d332259e16758bc43201073db91409390be9134 | UM/Operations/GroupedOperation.py | UM/Operations/GroupedOperation.py |
from . import Operation
## An operation that groups several other operations together.
#
# The intent of this operation is to hide an underlying chain of operations
# from the user if they correspond to only one interaction with the user, such
# as an operation applied to multiple scene nodes or a re-arrangeme... |
from . import Operation
## An operation that groups several other operations together.
#
# The intent of this operation is to hide an underlying chain of operations
# from the user if they correspond to only one interaction with the user, such
# as an operation applied to multiple scene nodes or a re-arrangeme... | Remove removeOperation from grouped operation | Remove removeOperation from grouped operation
This function is never used and actually should never be used. The operation may not be modified after it is used, so removing an operation from the list makes no sense.
| Python | agpl-3.0 | onitake/Uranium,onitake/Uranium |
from . import Operation
## An operation that groups several other operations together.
#
# The intent of this operation is to hide an underlying chain of operations
# from the user if they correspond to only one interaction with the user, such
# as an operation applied to multiple scene nodes o... | Remove removeOperation from grouped operation | ## Code Before:
from . import Operation
## An operation that groups several other operations together.
#
# The intent of this operation is to hide an underlying chain of operations
# from the user if they correspond to only one interaction with the user, such
# as an operation applied to multiple scene nodes o... | # ... existing code ...
## Undo all operations in this group.
# ... rest of the code ... |
3864ef6773000d516ee6542a11db3c3b636d5b49 | test/framework/killer.py | test/framework/killer.py |
from __future__ import print_function
import sys, os, signal, time, subprocess32
def _killer(pid, sleep_time, num_kills):
print("\nKiller going to sleep for", sleep_time, "seconds")
time.sleep(sleep_time)
print("\nKiller woke up")
for ii in range(0, num_kills):
os.kill(pid, signal.SIGTERM)
... |
from __future__ import print_function
import sys, os, signal, time, subprocess32
sys.path.append('../../..')
from jenkinsflow.mocked import hyperspeed
def _killer(pid, sleep_time, num_kills):
print("\nKiller going to sleep for", sleep_time, "seconds")
time.sleep(sleep_time)
print("\nKiller woke up")
... | Prepare kill test for mock - use hyperspeed | Prepare kill test for mock - use hyperspeed
| Python | bsd-3-clause | lhupfeldt/jenkinsflow,lechat/jenkinsflow,lhupfeldt/jenkinsflow,lhupfeldt/jenkinsflow,lechat/jenkinsflow,lhupfeldt/jenkinsflow,lechat/jenkinsflow,lechat/jenkinsflow |
from __future__ import print_function
import sys, os, signal, time, subprocess32
+
+ sys.path.append('../../..')
+ from jenkinsflow.mocked import hyperspeed
def _killer(pid, sleep_time, num_kills):
print("\nKiller going to sleep for", sleep_time, "seconds")
time.sleep(sleep_time)
pr... | Prepare kill test for mock - use hyperspeed | ## Code Before:
from __future__ import print_function
import sys, os, signal, time, subprocess32
def _killer(pid, sleep_time, num_kills):
print("\nKiller going to sleep for", sleep_time, "seconds")
time.sleep(sleep_time)
print("\nKiller woke up")
for ii in range(0, num_kills):
os.kill(pid, s... | // ... existing code ...
import sys, os, signal, time, subprocess32
sys.path.append('../../..')
from jenkinsflow.mocked import hyperspeed
// ... modified code ...
print("\nKiller sent", ii + 1, "of", num_kills, "SIGTERM signals to ", pid)
hyperspeed.sleep(1)
// ... rest of the code ... |
f2005fadb9fb2e2bcad32286a9d993c291c1992e | lazyblacksmith/models/api/industry_index.py | lazyblacksmith/models/api/industry_index.py | from . import db
from lazyblacksmith.models import Activity
class IndustryIndex(db.Model):
solarsystem_id = db.Column(
db.Integer, db.ForeignKey('solar_system.id'), primary_key=True
)
solarsystem = db.relationship('SolarSystem', backref=db.backref('indexes'))
activity = db.Column(db.Integer,... | from . import db
from lazyblacksmith.models import Activity
class IndustryIndex(db.Model):
solarsystem_id = db.Column(
db.Integer, db.ForeignKey('solar_system.id'), primary_key=True
)
solarsystem = db.relationship('SolarSystem', backref=db.backref('indexes'))
activity = db.Column(db.Integer,... | Fix celery task for industry indexes by adding missing field | Fix celery task for industry indexes by adding missing field
| Python | bsd-3-clause | Kyria/LazyBlacksmith,Kyria/LazyBlacksmith,Kyria/LazyBlacksmith,Kyria/LazyBlacksmith | from . import db
from lazyblacksmith.models import Activity
class IndustryIndex(db.Model):
solarsystem_id = db.Column(
db.Integer, db.ForeignKey('solar_system.id'), primary_key=True
)
solarsystem = db.relationship('SolarSystem', backref=db.backref('indexes'))
activity... | Fix celery task for industry indexes by adding missing field | ## Code Before:
from . import db
from lazyblacksmith.models import Activity
class IndustryIndex(db.Model):
solarsystem_id = db.Column(
db.Integer, db.ForeignKey('solar_system.id'), primary_key=True
)
solarsystem = db.relationship('SolarSystem', backref=db.backref('indexes'))
activity = db.Co... | // ... existing code ...
return Activity.COPYING
if activity_string == 'reaction':
return Activity.REACTIONS
// ... rest of the code ... |
497313620772c1cb0d520be1a0024c12ca02742e | tests/python_tests/fontset_test.py | tests/python_tests/fontset_test.py |
from nose.tools import *
from utilities import execution_path
import os, mapnik
def setup():
# All of the paths used are relative, if we run the tests
# from another directory we need to chdir()
os.chdir(execution_path('.'))
def test_loading_fontset_from_map():
m = mapnik.Map(256,256)
mapnik.loa... |
from nose.tools import *
from utilities import execution_path
import os, mapnik
def setup():
# All of the paths used are relative, if we run the tests
# from another directory we need to chdir()
os.chdir(execution_path('.'))
def test_loading_fontset_from_map():
m = mapnik.Map(256,256)
mapnik.loa... | Add a test (currently failing) ensuring that named fontsets created in python are propertly serialized | Add a test (currently failing) ensuring that named fontsets created in python are propertly serialized
| Python | lgpl-2.1 | Mappy/mapnik,qianwenming/mapnik,tomhughes/mapnik,jwomeara/mapnik,pnorman/mapnik,davenquinn/python-mapnik,yiqingj/work,pnorman/mapnik,Mappy/mapnik,yohanboniface/python-mapnik,mapycz/python-mapnik,jwomeara/mapnik,Mappy/mapnik,yiqingj/work,strk/mapnik,kapouer/mapnik,Mappy/mapnik,qianwenming/mapnik,lightmare/mapnik,garnert... |
from nose.tools import *
from utilities import execution_path
import os, mapnik
def setup():
# All of the paths used are relative, if we run the tests
# from another directory we need to chdir()
os.chdir(execution_path('.'))
def test_loading_fontset_from_map():
m = mapnik.M... | Add a test (currently failing) ensuring that named fontsets created in python are propertly serialized | ## Code Before:
from nose.tools import *
from utilities import execution_path
import os, mapnik
def setup():
# All of the paths used are relative, if we run the tests
# from another directory we need to chdir()
os.chdir(execution_path('.'))
def test_loading_fontset_from_map():
m = mapnik.Map(256,256... | ...
def test_loading_fontset_from_python():
m = mapnik.Map(256,256)
fset = mapnik.FontSet('my-set')
fset.add_face_name('Comic Sans')
fset.add_face_name('Papyrus')
m.append_fontset('my-set', fset)
sty = mapnik.Style()
rule = mapnik.Rule()
tsym = mapnik.TextSymbolizer()
tsym.fonts... |
85c509913cc9a6b22036c33eccb07277b39260e3 | pygraphc/anomaly/AnomalyScore.py | pygraphc/anomaly/AnomalyScore.py | import csv
from pygraphc.abstraction.ClusterAbstraction import ClusterAbstraction
from pygraphc.clustering.ClusterUtility import ClusterUtility
class AnomalyScore(object):
"""A class to calculate anomaly score in a cluster.
"""
def __init__(self, graph, clusters, filename):
"""The constructor of ... | import csv
from pygraphc.abstraction.ClusterAbstraction import ClusterAbstraction
from pygraphc.clustering.ClusterUtility import ClusterUtility
class AnomalyScore(object):
"""A class to calculate anomaly score in a cluster.
"""
def __init__(self, graph, clusters, filename):
"""The constructor of c... | Add description of Parameters section in docstring | Add description of Parameters section in docstring
| Python | mit | studiawan/pygraphc | import csv
-
from pygraphc.abstraction.ClusterAbstraction import ClusterAbstraction
from pygraphc.clustering.ClusterUtility import ClusterUtility
class AnomalyScore(object):
"""A class to calculate anomaly score in a cluster.
"""
def __init__(self, graph, clusters, filename):
... | Add description of Parameters section in docstring | ## Code Before:
import csv
from pygraphc.abstraction.ClusterAbstraction import ClusterAbstraction
from pygraphc.clustering.ClusterUtility import ClusterUtility
class AnomalyScore(object):
"""A class to calculate anomaly score in a cluster.
"""
def __init__(self, graph, clusters, filename):
"""The... | ...
import csv
from pygraphc.abstraction.ClusterAbstraction import ClusterAbstraction
...
graph : graph
A graph to be analyzed for its anomaly.
clusters : dict[list]
Dictionary of list containing node identifier for each clusters.
filename : str
... |
7539a5445d24193395eed5dc658a4e69d8782736 | buffpy/tests/test_profile.py | buffpy/tests/test_profile.py | from nose.tools import eq_
from mock import MagicMock, patch
from buffpy.models.profile import Profile, PATHS
mocked_response = {
'name': 'me',
'service': 'twiter',
'id': 1
}
def test_profile_schedules_getter():
'''
Test schedules gettering from buffer api
'''
mocked_api = MagicMock()
mocked_api.g... | from unittest.mock import MagicMock, patch
from buffpy.models.profile import Profile, PATHS
mocked_response = {
"name": "me",
"service": "twiter",
"id": 1
}
def test_profile_schedules_getter():
""" Should retrieve profiles from buffer's API. """
mocked_api = MagicMock()
mocked_api.get.retu... | Migrate profile tests to pytest | Migrate profile tests to pytest
| Python | mit | vtemian/buffpy | - from nose.tools import eq_
- from mock import MagicMock, patch
+ from unittest.mock import MagicMock, patch
from buffpy.models.profile import Profile, PATHS
+
mocked_response = {
- 'name': 'me',
+ "name": "me",
- 'service': 'twiter',
+ "service": "twiter",
- 'id': 1
+ "id": 1
}
+
... | Migrate profile tests to pytest | ## Code Before:
from nose.tools import eq_
from mock import MagicMock, patch
from buffpy.models.profile import Profile, PATHS
mocked_response = {
'name': 'me',
'service': 'twiter',
'id': 1
}
def test_profile_schedules_getter():
'''
Test schedules gettering from buffer api
'''
mocked_api = MagicMock(... | // ... existing code ...
from unittest.mock import MagicMock, patch
// ... modified code ...
mocked_response = {
"name": "me",
"service": "twiter",
"id": 1
}
...
def test_profile_schedules_getter():
""" Should retrieve profiles from buffer's API. """
mocked_api = MagicMock()
... |
959897478bbda18f02aa6e38f2ebdd837581f1f0 | tests/test_sct_verify_signature.py | tests/test_sct_verify_signature.py | from os.path import join, dirname
from utlz import flo
from ctutlz.sct.verification import verify_signature
def test_verify_signature():
basedir = join(dirname(__file__), 'data', 'test_sct_verify_signature')
signature_input = \
open(flo('{basedir}/signature_input_valid.bin'), 'rb').read()
signa... | from os.path import join, dirname
from utlz import flo
from ctutlz.sct.verification import verify_signature
def test_verify_signature():
basedir = join(dirname(__file__), 'data', 'test_sct_verify_signature')
signature_input = \
open(flo('{basedir}/signature_input_valid.bin'), 'rb').read()
signa... | Fix test for changed SctVerificationResult | Fix test for changed SctVerificationResult
| Python | mit | theno/ctutlz,theno/ctutlz | from os.path import join, dirname
from utlz import flo
from ctutlz.sct.verification import verify_signature
def test_verify_signature():
basedir = join(dirname(__file__), 'data', 'test_sct_verify_signature')
signature_input = \
open(flo('{basedir}/signature_input_valid.bin')... | Fix test for changed SctVerificationResult | ## Code Before:
from os.path import join, dirname
from utlz import flo
from ctutlz.sct.verification import verify_signature
def test_verify_signature():
basedir = join(dirname(__file__), 'data', 'test_sct_verify_signature')
signature_input = \
open(flo('{basedir}/signature_input_valid.bin'), 'rb').... | # ... existing code ...
assert verify_signature(signature_input, signature, pubkey) is True
# ... modified code ...
assert verify_signature(signature_input, signature, pubkey) is False
# ... rest of the code ... |
dbec204b242ab643de162046ba73dca32043c6c2 | space-age/space_age.py | space-age/space_age.py | class SpaceAge(object):
def __init__(self, seconds):
self.seconds = seconds
@property
def years(self):
return self.seconds/31557600
def on_earth(self):
return round(self.years, 2)
def on_mercury(self):
return round(self.years/0.2408467, 2)
def on_venus(self):
... | class SpaceAge(object):
YEARS = {"on_earth": 1,
"on_mercury": 0.2408467,
"on_venus": 0.61519726,
"on_mars": 1.8808158,
"on_jupiter": 11.862615,
"on_saturn": 29.447498,
"on_uranus": 84.016846,
"on_neptune": 164.79132}
def... | Implement __getattr__ to reduce code | Implement __getattr__ to reduce code
| Python | agpl-3.0 | CubicComet/exercism-python-solutions | class SpaceAge(object):
+ YEARS = {"on_earth": 1,
+ "on_mercury": 0.2408467,
+ "on_venus": 0.61519726,
+ "on_mars": 1.8808158,
+ "on_jupiter": 11.862615,
+ "on_saturn": 29.447498,
+ "on_uranus": 84.016846,
+ "on_neptune": 1... | Implement __getattr__ to reduce code | ## Code Before:
class SpaceAge(object):
def __init__(self, seconds):
self.seconds = seconds
@property
def years(self):
return self.seconds/31557600
def on_earth(self):
return round(self.years, 2)
def on_mercury(self):
return round(self.years/0.2408467, 2)
def ... | # ... existing code ...
class SpaceAge(object):
YEARS = {"on_earth": 1,
"on_mercury": 0.2408467,
"on_venus": 0.61519726,
"on_mars": 1.8808158,
"on_jupiter": 11.862615,
"on_saturn": 29.447498,
"on_uranus": 84.016846,
"on_ne... |
3c65881633daee8d5b19760e5c887dce25ab69c3 | froide/helper/db_utils.py | froide/helper/db_utils.py | from django.db import IntegrityError
from django.template.defaultfilters import slugify
def save_obj_with_slug(obj, attribute='title', **kwargs):
obj.slug = slugify(getattr(obj, attribute))
return save_obj_unique(obj, 'slug', **kwargs)
def save_obj_unique(obj, attr, count=0, postfix_format='-{count}'):
... | from django.db import IntegrityError
from django.template.defaultfilters import slugify
def save_obj_with_slug(obj, attribute='title', **kwargs):
obj.slug = slugify(getattr(obj, attribute))
return save_obj_unique(obj, 'slug', **kwargs)
def save_obj_unique(obj, attr, count=0, postfix_format='-{count}'):
... | Fix bad initial count in slug creation helper | Fix bad initial count in slug creation helper | Python | mit | stefanw/froide,stefanw/froide,stefanw/froide,fin/froide,fin/froide,fin/froide,fin/froide,stefanw/froide,stefanw/froide | from django.db import IntegrityError
from django.template.defaultfilters import slugify
def save_obj_with_slug(obj, attribute='title', **kwargs):
obj.slug = slugify(getattr(obj, attribute))
return save_obj_unique(obj, 'slug', **kwargs)
def save_obj_unique(obj, attr, count=0, postfix_form... | Fix bad initial count in slug creation helper | ## Code Before:
from django.db import IntegrityError
from django.template.defaultfilters import slugify
def save_obj_with_slug(obj, attribute='title', **kwargs):
obj.slug = slugify(getattr(obj, attribute))
return save_obj_unique(obj, 'slug', **kwargs)
def save_obj_unique(obj, attr, count=0, postfix_format='... | ...
first_round = False
count = max(
klass.objects.filter(**{
'%s__startswith' % attr: base_attr
}).count(),
initial_count
)
else:
...
... |
b06f0e17541f7d424e73fd200ae10db0722b1a5a | organizer/views.py | organizer/views.py | from django.shortcuts import (
get_object_or_404, render)
from .forms import TagForm
from .models import Startup, Tag
def startup_detail(request, slug):
startup = get_object_or_404(
Startup, slug__iexact=slug)
return render(
request,
'organizer/startup_detail.html',
{'star... | from django.shortcuts import (
get_object_or_404, redirect, render)
from .forms import TagForm
from .models import Startup, Tag
def startup_detail(request, slug):
startup = get_object_or_404(
Startup, slug__iexact=slug)
return render(
request,
'organizer/startup_detail.html',
... | Create and redirect to Tag in tag_create(). | Ch09: Create and redirect to Tag in tag_create().
| Python | bsd-2-clause | jambonrose/DjangoUnleashed-1.8,jambonrose/DjangoUnleashed-1.8 | from django.shortcuts import (
- get_object_or_404, render)
+ get_object_or_404, redirect, render)
from .forms import TagForm
from .models import Startup, Tag
def startup_detail(request, slug):
startup = get_object_or_404(
Startup, slug__iexact=slug)
return render(
... | Create and redirect to Tag in tag_create(). | ## Code Before:
from django.shortcuts import (
get_object_or_404, render)
from .forms import TagForm
from .models import Startup, Tag
def startup_detail(request, slug):
startup = get_object_or_404(
Startup, slug__iexact=slug)
return render(
request,
'organizer/startup_detail.html'... | # ... existing code ...
from django.shortcuts import (
get_object_or_404, redirect, render)
# ... modified code ...
if form.is_valid():
new_tag = form.save()
return redirect(new_tag)
else: # empty data or invalid data
# ... rest of the code ... |
End of preview. Expand in Data Studio
README.md exists but content is empty.
- Downloads last month
- 3