Unnamed: 0
int64
0
10k
function
stringlengths
79
138k
label
stringclasses
20 values
info
stringlengths
42
261
4,000
def test_is_greater_than_or_equal_to_bad_arg_type_failure(self): try: assert_that(self.d1).is_greater_than_or_equal_to(123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be <datetime>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_greater_than_or_equal_to_bad_arg_type_failure
4,001
def test_is_less_than_failure(self): try: d2 = datetime.datetime.today() assert_that(d2).is_less_than(self.d1) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}> to be less t...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_less_than_failure
4,002
def test_is_less_than_bad_arg_type_failure(self): try: assert_that(self.d1).is_less_than(123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be <datetime>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_less_than_bad_arg_type_failure
4,003
def test_is_less_than_or_equal_to_failure(self): try: d2 = datetime.datetime.today() assert_that(d2).is_less_than_or_equal_to(self.d1) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{4}-\d{2}-\d{2} \d{2}:\...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_less_than_or_equal_to_failure
4,004
def test_is_less_than_or_equal_to_bad_arg_type_failure(self): try: assert_that(self.d1).is_less_than_or_equal_to(123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be <datetime>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_less_than_or_equal_to_bad_arg_type_failure
4,005
def test_is_between_failure(self): try: d2 = datetime.datetime.today() d3 = datetime.datetime.today() assert_that(self.d1).is_between(d2, d3) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{4}-...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_between_failure
4,006
def test_is_between_bad_arg1_type_failure(self): try: assert_that(self.d1).is_between(123, 456) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given low arg must be <datetime>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_between_bad_arg1_type_failure
4,007
def test_is_between_bad_arg2_type_failure(self): try: d2 = datetime.datetime.today() assert_that(self.d1).is_between(d2, 123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given high arg must be <datetime>, but w...
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_between_bad_arg2_type_failure
4,008
def test_is_close_to_failure(self): try: d2 = self.d1 + datetime.timedelta(minutes=5) assert_that(self.d1).is_close_to(d2, datetime.timedelta(minutes=1)) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{4}-...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_close_to_failure
4,009
def test_is_close_to_bad_arg_type_failure(self): try: assert_that(self.d1).is_close_to(123, 456) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be datetime, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_close_to_bad_arg_type_failure
4,010
def test_is_close_to_bad_tolerance_arg_type_failure(self): try: d2 = datetime.datetime.today() assert_that(self.d1).is_close_to(d2, 123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given tolerance arg must be t...
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestDate.test_is_close_to_bad_tolerance_arg_type_failure
4,011
def test_is_greater_than_failure(self): try: t2 = datetime.timedelta(seconds=90) assert_that(self.t1).is_greater_than(t2) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{1,2}:\d{2}:\d{2}> to be greater tha...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_greater_than_failure
4,012
def test_is_greater_than_bad_arg_type_failure(self): try: assert_that(self.t1).is_greater_than(123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be <timedelta>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_greater_than_bad_arg_type_failure
4,013
def test_is_greater_than_or_equal_to_failure(self): try: t2 = datetime.timedelta(seconds=90) assert_that(self.t1).is_greater_than_or_equal_to(t2) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{1,2}:\d{2}:...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_greater_than_or_equal_to_failure
4,014
def test_is_greater_than_or_equal_to_bad_arg_type_failure(self): try: assert_that(self.t1).is_greater_than_or_equal_to(123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be <timedelta>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_greater_than_or_equal_to_bad_arg_type_failure
4,015
def test_is_less_than_failure(self): try: t2 = datetime.timedelta(seconds=90) assert_that(t2).is_less_than(self.t1) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{1,2}:\d{2}:\d{2}> to be less than <\d{1,2...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_less_than_failure
4,016
def test_is_less_than_bad_arg_type_failure(self): try: assert_that(self.t1).is_less_than(123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be <timedelta>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_less_than_bad_arg_type_failure
4,017
def test_is_less_than_or_equal_to_failure(self): try: t2 = datetime.timedelta(seconds=90) assert_that(t2).is_less_than_or_equal_to(self.t1) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expected <\d{1,2}:\d{2}:\d{2}>...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_less_than_or_equal_to_failure
4,018
def test_is_less_than_or_equal_to_bad_arg_type_failure(self): try: assert_that(self.t1).is_less_than_or_equal_to(123) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).is_equal_to('given arg must be <timedelta>, but was <int>')
TypeError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_less_than_or_equal_to_bad_arg_type_failure
4,019
def test_is_between_failure(self): try: d2 = datetime.timedelta(seconds=30) d3 = datetime.timedelta(seconds=40) assert_that(self.t1).is_between(d2, d3) fail('should have raised error') except __HOLE__ as ex: assert_that(str(ex)).matches('Expect...
AssertionError
dataset/ETHPy150Open ActivisionGameScience/assertpy/tests/test_datetime.py/TestTimedelta.test_is_between_failure
4,020
def __getitem__(self, item): try: return self.data[int(item)] except __HOLE__: return getattr(self, item)
ValueError
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/SOAPpy/Types.py/arrayType.__getitem__
4,021
def _setDetail(self, detail = None): if detail != None: self.detail = detail else: try: del self.detail except __HOLE__: pass
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/api/SOAPpy/Types.py/faultType._setDetail
4,022
@internationalizeDocstring def lart(self, irc, msg, args, channel, id, text): """[<channel>] [<id>] <who|what> [for <reason>] Uses the Luser Attitude Readjustment Tool on <who|what> (for <reason>, if given). If <id> is given, uses that specific lart. <channel> is only necessary if...
KeyError
dataset/ETHPy150Open ProgVal/Limnoria/plugins/Lart/plugin.py/Lart.lart
4,023
@option( '-k', '--kernel_name', action='store', default="default", help='arbitrary name given to reference kernel' ) @option( '-i', '--ids', action='store', default=None, help='the machine ids to use from the cluster' ) def line_parallel(self, module_name, class_...
ImportError
dataset/ETHPy150Open Calysto/metakernel/metakernel/magics/parallel_magic.py/ParallelMagic.line_parallel
4,024
def line_pmap(self, function_name, args, kernel_name=None): """ %pmap FUNCTION [ARGS1,ARGS2,...] - ("parallel map") call a FUNCTION on args This line magic will apply a function name to all of the arguments given one at a time using a dynamic load balancing scheduler. Currently...
ImportError
dataset/ETHPy150Open Calysto/metakernel/metakernel/magics/parallel_magic.py/ParallelMagic.line_pmap
4,025
def startService(self): Service.startService(self) parent = self._config_path.parent() try: if not parent.exists(): parent.makedirs() if not self._config_path.exists(): uuid = unicode(uuid4()) self._config_path.setContent(js...
OSError
dataset/ETHPy150Open ClusterHQ/flocker/flocker/volume/service.py/VolumeService.startService
4,026
def enumerate(self): """Get a listing of all volumes managed by this service. :return: A ``Deferred`` that fires with an iterator of :class:`Volume`. """ enumerating = self.pool.enumerate() def enumerated(filesystems): for filesystem in filesystems: ...
ValueError
dataset/ETHPy150Open ClusterHQ/flocker/flocker/volume/service.py/VolumeService.enumerate
4,027
def draw_rectangle(self, x, y, width, height): # Nasty retry if the image is loaded for the first time and it's truncated try: d = ImageDraw.Draw(self.image) except __HOLE__: d = ImageDraw.Draw(self.image) d.rectangle([x, y, x + width, y + height]) del d
IOError
dataset/ETHPy150Open thumbor/thumbor/thumbor/engines/pil.py/Engine.draw_rectangle
4,028
def read(self, extension=None, quality=None): # NOQA # returns image buffer in byte format. img_buffer = BytesIO() ext = extension or self.extension or self.get_default_extension() options = { 'quality': quality } if ext == '.jpg' or ext == '.jpeg': ...
IOError
dataset/ETHPy150Open thumbor/thumbor/thumbor/engines/pil.py/Engine.read
4,029
def _format_fixed_ips(port): try: return '\n'.join([jsonutils.dumps(ip) for ip in port['fixed_ips']]) except (TypeError, __HOLE__): return ''
KeyError
dataset/ETHPy150Open openstack/python-neutronclient/neutronclient/neutron/v2_0/port.py/_format_fixed_ips
4,030
def _format_fixed_ips_csv(port): try: return jsonutils.dumps(port['fixed_ips']) except (__HOLE__, KeyError): return ''
TypeError
dataset/ETHPy150Open openstack/python-neutronclient/neutronclient/neutron/v2_0/port.py/_format_fixed_ips_csv
4,031
def gather_modules(): """Collect the information and construct the output.""" reqs = {} errors = [] output = [] for package in sorted(explore_module('homeassistant.components', True)): try: module = importlib.import_module(package) except __HOLE__: errors.ap...
ImportError
dataset/ETHPy150Open home-assistant/home-assistant/script/gen_requirements_all.py/gather_modules
4,032
def runjobs_by_signals(self, when, options): """ Run jobs from the signals """ # Thanks for Ian Holsman for the idea and code from django_extensions.management import signals from django.db import models from django.conf import settings verbosity = int(options.get('verbo...
ImportError
dataset/ETHPy150Open mozilla/inventory/vendor-local/src/django-extensions/build/lib/django_extensions/management/commands/runjobs.py/Command.runjobs_by_signals
4,033
def configure(current_node=None): """Deploy chef-solo specific files""" current_node = current_node or {} # Ensure that the /tmp/chef-solo/cache directory exist cache_dir = "{0}/cache".format(env.node_work_path) # First remote call, could go wrong try: cache_exists = exists(cache_dir) ...
SystemExit
dataset/ETHPy150Open tobami/littlechef/littlechef/solo.py/configure
4,034
def _loadregisry(): try: with open(_REG_FILENAME) as f: #(3) return json.load(f) except __HOLE__: #(4) return {}
IOError
dataset/ETHPy150Open rgalanakis/practicalmayapython/src/chapter5/newmenumarker.py/_loadregisry
4,035
@property def OptionParser(self): if self._optparse is None: try: me = 'repo %s' % self.NAME usage = self.helpUsage.strip().replace('%prog', me) except __HOLE__: usage = 'repo %s' % self.NAME self._optparse = optparse.OptionParser(usage = usage) self._Options(self._...
AttributeError
dataset/ETHPy150Open ossxp-com/repo/command.py/Command.OptionParser
4,036
def GetProjects(self, args, missing_ok=False): """A list of projects that match the arguments. """ all = self.manifest.projects result = [] if not args: for project in all.values(): if missing_ok or project.Exists: result.append(project) else: by_path = None ...
KeyError
dataset/ETHPy150Open ossxp-com/repo/command.py/Command.GetProjects
4,037
def apply_patch(self, patch_file, base_path, base_dir, p=None, revert=False): """Apply the patch and return a PatchResult indicating its success.""" # Figure out the -p argument for patch. We override the calculated # value if it is supplied via a commandline option. ...
IOError
dataset/ETHPy150Open reviewboard/rbtools/rbtools/clients/__init__.py/SCMClient.apply_patch
4,038
@not_implemented_for('multigraph') def katz_centrality(G, alpha=0.1, beta=1.0, max_iter=1000, tol=1.0e-6, nstart=None, normalized=True): r"""Compute the Katz centrality for the nodes of the graph G. Katz centrality is related to eigenvalue centrality and PageRank. The Katz centrality f...
ValueError
dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/centrality/katz.py/katz_centrality
4,039
@not_implemented_for('multigraph') def katz_centrality_numpy(G, alpha=0.1, beta=1.0, normalized=True): r"""Compute the Katz centrality for the graph G. Katz centrality is related to eigenvalue centrality and PageRank. The Katz centrality for node `i` is .. math:: x_i = \alpha \sum_{j} A_{ij}...
ValueError
dataset/ETHPy150Open gkno/gkno_launcher/src/networkx/algorithms/centrality/katz.py/katz_centrality_numpy
4,040
def _load_file(self, name): try: path = os.path.join(BAT_DIR, self.battery_name, name) with open(path, 'r') as f: return f.read().strip() except __HOLE__: if name == 'current_now': return 0 return False except Except...
IOError
dataset/ETHPy150Open qtile/qtile/libqtile/widget/battery.py/_Battery._load_file
4,041
def _get_info(self): try: info = { 'stat': self._get_param('status_file'), 'now': float(self._get_param('energy_now_file')), 'full': float(self._get_param('energy_full_file')), 'power': float(self._get_param('power_now_file')), ...
TypeError
dataset/ETHPy150Open qtile/qtile/libqtile/widget/battery.py/_Battery._get_info
4,042
def _check_zipfile(fp): try: if _EndRecData(fp): return True # file has correct magic number except __HOLE__: pass return False
IOError
dataset/ETHPy150Open AndroBugs/AndroBugs_Framework/tools/modified/androguard/patch/zipfile.py/_check_zipfile
4,043
def is_zipfile(filename): """Quickly see if a file is a ZIP file by checking the magic number. The filename argument may be a file or file-like object too. """ result = False try: if hasattr(filename, "read"): result = _check_zipfile(fp=filename) else: with o...
IOError
dataset/ETHPy150Open AndroBugs/AndroBugs_Framework/tools/modified/androguard/patch/zipfile.py/is_zipfile
4,044
def _EndRecData64(fpin, offset, endrec): """ Read the ZIP64 end-of-archive records and use that to update endrec """ try: fpin.seek(offset - sizeEndCentDir64Locator, 2) except __HOLE__: # If the seek fails, the file is not large enough to contain a ZIP64 # end-of-archive reco...
IOError
dataset/ETHPy150Open AndroBugs/AndroBugs_Framework/tools/modified/androguard/patch/zipfile.py/_EndRecData64
4,045
def _EndRecData(fpin): """Return data from the "End of Central Directory" record, or None. The data is a list of the nine items in the ZIP "End of central dir" record followed by a tenth item, the file seek offset of this record.""" # Determine file size fpin.seek(0, 2) filesize = fpin.tell() ...
IOError
dataset/ETHPy150Open AndroBugs/AndroBugs_Framework/tools/modified/androguard/patch/zipfile.py/_EndRecData
4,046
def __init__(self, file, mode="r", compression=ZIP_STORED, allowZip64=False): """Open the ZIP file with mode read "r", write "w" or append "a".""" if mode not in ("r", "w", "a"): raise RuntimeError('ZipFile() requires mode "r", "w", or "a"') if compression == ZIP_STORED: ...
IOError
dataset/ETHPy150Open AndroBugs/AndroBugs_Framework/tools/modified/androguard/patch/zipfile.py/ZipFile.__init__
4,047
def _RealGetContents(self): """Read in the table of contents for the ZIP file.""" fp = self.fp try: endrec = _EndRecData(fp) except __HOLE__: raise BadZipfile("File is not a zip file") if not endrec: raise BadZipfile, "File is not a zip file" ...
IOError
dataset/ETHPy150Open AndroBugs/AndroBugs_Framework/tools/modified/androguard/patch/zipfile.py/ZipFile._RealGetContents
4,048
def add(self, key): key = key.strip() try: return self.dct[key] except __HOLE__: res = self.dct[key] = self.counter self.counter += 1 return res
KeyError
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/tablib-0.10.0/tablib/packages/openpyxl/writer/strings.py/StringTableBuilder.add
4,049
def _get_resource(package_name, resource, return_binary=False, encoding="utf-8"): packages_path = sublime.packages_path() content = None if VERSION > 3013: try: if return_binary: content = sublime.load_binary_resource("Packages/" + package_name + "/" + resource) ...
IOError
dataset/ETHPy150Open chrisbreiding/ASCIIPresentation/lib/package_resources.py/_get_resource
4,050
def get_as_num(value): """Return the JS numeric equivalent for a value.""" if hasattr(value, 'get_literal_value'): value = value.get_literal_value() if value is None: return 0 try: if isinstance(value, types.StringTypes): if value.startswith("0x"): r...
TypeError
dataset/ETHPy150Open mozilla/app-validator/appvalidator/testcases/javascript/utils.py/get_as_num
4,051
def get_as_str(value): """Return the JS string equivalent for a literal value.""" if hasattr(value, 'get_literal_value'): value = value.get_literal_value() if value is None: return "" if isinstance(value, bool): return u"true" if value else u"false" elif isinstance(value, (...
TypeError
dataset/ETHPy150Open mozilla/app-validator/appvalidator/testcases/javascript/utils.py/get_as_str
4,052
@register.filter def parse_isotime(timestr, default=None): """This duplicates oslo timeutils parse_isotime but with a @register.filter annotation and a silent fallback on error. """ try: return iso8601.parse_date(timestr) except (iso8601.ParseError, __HOLE__): return default or ''
TypeError
dataset/ETHPy150Open Havate/havate-openstack/proto-build/gui/horizon/Horizon_GUI/horizon/utils/filters.py/parse_isotime
4,053
def create_initial_security_groups(sender, instance=None, created=False, **kwargs): if not created: return nc_settings = getattr(settings, 'NODECONDUCTOR', {}) config_groups = nc_settings.get('DEFAULT_SECURITY_GROUPS', []) for group in config_groups: sg_name = group.get('name') ...
ValidationError
dataset/ETHPy150Open opennode/nodeconductor/nodeconductor/openstack/handlers.py/create_initial_security_groups
4,054
def build_config_from_file(module): """Build module info from `app/config/desktop.py` files.""" data = [] module = frappe.scrub(module) for app in frappe.get_installed_apps(): try: data += get_config(app, module) except __HOLE__: pass return data
ImportError
dataset/ETHPy150Open frappe/frappe/frappe/desk/moduleview.py/build_config_from_file
4,055
def add_setup_section(config, app, module, label, icon): """Add common sections to `/desk#Module/Setup`""" try: setup_section = get_setup_section(app, module, label, icon) if setup_section: config.append(setup_section) except __HOLE__: pass
ImportError
dataset/ETHPy150Open frappe/frappe/frappe/desk/moduleview.py/add_setup_section
4,056
def get_class(datatype): # already done? if not isinstance(datatype, basestring): return datatype # parse datatype string "v31/Election" --> from v31 import Election parsed_datatype = datatype.split("/") # get the module dynamic_module = __import__(".".join(parsed_datatype[:-1]), g...
AttributeError
dataset/ETHPy150Open benadida/helios-server/helios/datatypes/__init__.py/get_class
4,057
def sentinel(name, doc=None): try: value = sentinel._cache[name] # memoized except __HOLE__: pass else: if doc == value.__doc__: return value raise ValueError(dedent( """\ New sentinel value %r conflicts with an existing sentinel of the ...
KeyError
dataset/ETHPy150Open quantopian/zipline/zipline/utils/sentinel.py/sentinel
4,058
def _format_value(val, limit, level, len=len, repr=repr): """Format an arbitrary value as a compact string. This is a variant on Python's built-in repr() function, also borrowing some ideas from the repr.py standard library module, but tuned for speed even in extreme cases (like very large longs or very long...
KeyError
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/ext/appstats/formatting.py/_format_value
4,059
def process_file(fn, lines): lines.insert(0, '\n') lines.insert(0, '.. %s:\n' % target_name(fn)) try: f = open(fn, 'w') except __HOLE__: print("Can't open %s for writing. Not touching it." % fn) return try: f.writelines(lines) except IOError: print("Can't ...
IOError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/docs/_ext/applyxrefs.py/process_file
4,060
def has_target(fn): try: f = open(fn, 'r') except __HOLE__: print("Can't open %s. Not touching it." % fn) return (True, None) readok = True try: lines = f.readlines() except IOError: print("Can't read %s. Not touching it." % fn) readok = False fina...
IOError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/docs/_ext/applyxrefs.py/has_target
4,061
def __init__(self, id_vendor=0x0fcf, id_product=0x1008, ep=1): for dev in usb.core.find(idVendor=id_vendor, idProduct=id_product, find_all=True): try: dev.set_configuration() usb.util.claim_interface(dev, 0) self.dev = dev self.ep = ep ...
IOError
dataset/ETHPy150Open braiden/python-ant-downloader/antd/hw.py/UsbHardware.__init__
4,062
def daemonize(stdin='/dev/null', stdout='/dev/null', stderr='/dev/null'): '''This forks the current process into a daemon. The stdin, stdout, and stderr arguments are file names that will be opened and be used to replace the standard file descriptors in sys.stdin, sys.stdout, and sys.stderr. These a...
OSError
dataset/ETHPy150Open jonathanslenders/python-deployer/deployer/daemonize.py/daemonize
4,063
def get_object_or_404(queryset, *args, **kwargs): """ replacement of rest_framework.generics and django.shrtcuts analogues """ try: return queryset.get(*args, **kwargs) except (__HOLE__, TypeError, DoesNotExist): raise Http404()
ValueError
dataset/ETHPy150Open umutbozkurt/django-rest-framework-mongoengine/rest_framework_mongoengine/generics.py/get_object_or_404
4,064
def get_comment_app(): """ Get the comment app (i.e. "django.contrib.comments") as defined in the settings """ # Make sure the app's in INSTALLED_APPS comments_app = get_comment_app_name() if comments_app not in settings.INSTALLED_APPS: raise ImproperlyConfigured("The COMMENTS_APP (%r) "...
ImportError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.2/django/contrib/comments/__init__.py/get_comment_app
4,065
def wrapped_f(self, f, *args, **kwargs): # At the first call, reset the time if self.__last_reset == None: self.__last_reset = datetime.datetime.now() if self.__numcalls >= self.__max_calls: time_delta = datetime.datetime.now() - self.__last_reset try: ...
AttributeError
dataset/ETHPy150Open themiurgo/ratelim/ratelim/__init__.py/greedy.wrapped_f
4,066
def wrapped_f(self, f, *args, **kwargs): now = datetime.datetime.now() # At the first call, reset the time if self.__last_call == None: self.__last_call = now return f(*args, **kwargs) time_delta = now - self.__last_call try: time_delta = int(...
AttributeError
dataset/ETHPy150Open themiurgo/ratelim/ratelim/__init__.py/patient.wrapped_f
4,067
def __new__(cls, *args): if not args: # clone constructor return object.__new__(cls) else: element, values = args # pull appropriate subclass from registry of annotated # classes try: cls = annotated_classes[element....
KeyError
dataset/ETHPy150Open zzzeek/sqlalchemy/lib/sqlalchemy/sql/annotation.py/Annotated.__new__
4,068
def to_global(prefix, mac, project_id): try: mac64 = netaddr.EUI(mac).eui64().words int_addr = int(''.join(['%02x' % i for i in mac64]), 16) mac64_addr = netaddr.IPAddress(int_addr) maskIP = netaddr.IPNetwork(prefix).ip return (mac64_addr ^ netaddr.IPAddress('::0200:0:0:0') |...
TypeError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/ipv6/rfc2462.py/to_global
4,069
def emit(self, record): """Emit a record.""" try: self.mailer.new(plain=self.format(record)).send() except (KeyboardInterrupt, __HOLE__): raise except: self.handleError(record)
SystemExit
dataset/ETHPy150Open marrow/mailer/marrow/mailer/logger.py/MailHandler.emit
4,070
def init_args(): parser = argparse.ArgumentParser( description='Generate Mantle models by a given JSON file.' ) parser.add_argument('json_file', help='the JSON file to be parsed') parser.add_argument('output_dir', help='output directory for generat...
IOError
dataset/ETHPy150Open sutar/JSON2Mantle/JSON2Mantle/cli.py/init_args
4,071
def main(): """ Main function """ args = init_args() try: dict_data = json.loads(open(args.json_file).read()) except __HOLE__: print('Error: no such file {}'.format(args.json_file)) exit() j2m = JSON2Mantle() # Gets meta data j2m.class_prefix = args.prefix if a...
IOError
dataset/ETHPy150Open sutar/JSON2Mantle/JSON2Mantle/cli.py/main
4,072
def clean(self, value): super(NOSocialSecurityNumber, self).clean(value) if value in EMPTY_VALUES: return '' if not re.match(r'^\d{11}$', value): raise ValidationError(self.error_messages['invalid']) day = int(value[:2]) month = int(value[2:4]) y...
ValueError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.5/django/contrib/localflavor/no/forms.py/NOSocialSecurityNumber.clean
4,073
def user_data(self, access_token, *args, **kwargs): """Loads user data from service""" user_id_url = kwargs.get('response').get('id') url = user_id_url + '?' + urlencode({'access_token': access_token}) try: return self.get_json(url) except __HOLE__: return...
ValueError
dataset/ETHPy150Open omab/python-social-auth/social/backends/salesforce.py/SalesforceOAuth2.user_data
4,074
def action(self, params): if len(params) == 0: return WrongParamResp() peer = afi = safi = None try: peer = params[0] afi = params[1] safi = params[2] except __HOLE__: pass self.api.route_refresh(peer, afi, safi) ...
IndexError
dataset/ETHPy150Open osrg/ryu/ryu/services/protocols/bgp/operator/commands/clear.py/BGPCmd.action
4,075
def action(self, params): peer = afi = safi = None try: afi = params[0] safi = params[1] except __HOLE__: pass self.api.route_refresh(peer, afi, safi) return CommandsResponse(STATUS_OK, '')
IndexError
dataset/ETHPy150Open osrg/ryu/ryu/services/protocols/bgp/operator/commands/clear.py/BGPCmd.All.action
4,076
def handle(self, *fixture_labels, **options): from django.db.models import get_apps from django.core import serializers from django.db import connection, transaction from django.conf import settings self.style = no_style() verbosity = int(options.get('verbosity', 1)) ...
SystemExit
dataset/ETHPy150Open CollabQ/CollabQ/vendor/django/core/management/commands/loaddata.py/Command.handle
4,077
def as_tuple(item, type=None, length=None): # Empty list if we get passed None if item is None: t = () else: # Convert iterable to list... try: t = tuple(item) # ... or create a list of a single item except (__HOLE__, NotImplementedError): t = ...
TypeError
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/as_tuple
4,078
def as_type(obj, typ): """Return obj if it is of dtype typ, otherwise return a copy type-cast to typ.""" # Assume it's a NumPy data type try: return obj if obj.dtype == typ else obj.astype(typ) except __HOLE__: if isinstance(obj, int): return np.int64(obj).astype(typ) ...
AttributeError
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/as_type
4,079
def tuplify(xs): """Turn a data structure into a tuple tree.""" try: return tuple(tuplify(x) for x in xs) except __HOLE__: return xs
TypeError
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/tuplify
4,080
def check_args(self, args, kwargs): for argname, argcond, exception in self._checks: # If the argument argname is not present in the decorated function # silently ignore it try: i = self.varnames.index(argname) except __HOLE__: # No...
ValueError
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/validate_base.check_args
4,081
def check_arg(self, arg, ignored, exception): try: np.dtype(arg) except __HOLE__: raise exception("%s:%d %s must be a valid dtype" % (self.file, self.line, arg))
TypeError
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/validate_dtype.check_arg
4,082
def verify_reshape(data, dtype, shape, allow_none=False): """Verify data is of type dtype and try to reshaped to shape.""" try: t = np.dtype(dtype) if dtype is not None else None except __HOLE__: raise DataTypeError("Invalid data type: %s" % dtype) if data is None and allow_none: ...
TypeError
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/verify_reshape
4,083
def get_petsc_dir(): try: arch = '/' + os.environ.get('PETSC_ARCH', '') dir = os.environ['PETSC_DIR'] return (dir, dir + arch) except __HOLE__: try: import petsc return (petsc.get_petsc_dir(), ) except ImportError: sys.exit("""Error: Co...
KeyError
dataset/ETHPy150Open OP2/PyOP2/pyop2/utils.py/get_petsc_dir
4,084
def SendStartRequest(self): """If the process has not been started, sends a request to /_ah/start.""" if self.started: return try: response = self.SendRequest('GET', '/_ah/start') rc = response.status if (rc >= 200 and rc < 300) or rc == 404: self.started = True except _...
KeyboardInterrupt
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/dev_appserver_multiprocess.py/ChildProcess.SendStartRequest
4,085
def PosixShutdown(): """Kills a posix process with os.kill.""" dev_process = GlobalProcess() children = dev_process.Children() for term_signal in (signal.SIGTERM, signal.SIGKILL): for child in children: if child.process is None: continue if child.process.returncode is not None: c...
OSError
dataset/ETHPy150Open AppScale/appscale/AppServer/google/appengine/tools/dev_appserver_multiprocess.py/PosixShutdown
4,086
def __init__(self): try: webanalytics_app = settings.WEBANALYTICS_APP if webanalytics_app == 'PIWIK': self.process_response = self.insert_piwik elif webanalytics_app == 'GOOGLE_ANALYTICS': self.process_response = self.insert_google_analytics ...
AttributeError
dataset/ETHPy150Open rennerocha/dojopuzzles/dojopuzzles/webanalytics/middleware.py/WebAnalyticsMiddleware.__init__
4,087
def lazyproperty(f): """ @lazyprop decorator. Decorated method will be called only on first access to calculate a cached property value. After that, the cached value is returned. """ cache_attr_name = '_%s' % f.__name__ # like '_foobar' for prop 'foobar' docstring = f.__doc__ def get_p...
AttributeError
dataset/ETHPy150Open scanny/python-pptx/pptx/util.py/lazyproperty
4,088
def clear_check(self): ch = self._clear_hook try: wr = list(ch)[0] except __HOLE__: self.clear_setup() else: c = wr() if c is None: self.clear_setup() elif self._root.sys.getrefcount(c) > 3: print 'GC hook object was referred to from somebody!' self.clear_callback(wr) c.cb.callback ...
IndexError
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/guppy-0.1.10/guppy/heapy/View.py/_GLUECLAMP_.clear_check
4,089
def obj_at(self, addr): try: return self.immnodeset(self.hv.static_types).obj_at(addr) except __HOLE__: pass try: return self.immnodeset(self.gc.get_objects()).obj_at(addr) except ValueError: pass try: return self.immnod...
ValueError
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/guppy-0.1.10/guppy/heapy/View.py/_GLUECLAMP_.obj_at
4,090
@staticmethod def _infimum_key(expr): """ Return infimum (if possible) else S.Infinity. """ try: infimum = expr.inf assert infimum.is_comparable except (NotImplementedError, AttributeError, AssertionError, __HOLE__): infimum...
ValueError
dataset/ETHPy150Open sympy/sympy/sympy/sets/sets.py/Set._infimum_key
4,091
def _contains(self, element): """ 'in' operator for ProductSets Examples ======== >>> from sympy import Interval >>> (2, 3) in Interval(0, 5) * Interval(0, 5) True >>> (10, 10) in Interval(0, 5) * Interval(0, 5) False Passes operation o...
TypeError
dataset/ETHPy150Open sympy/sympy/sympy/sets/sets.py/ProductSet._contains
4,092
def _eval_imageset(self, f): from sympy.functions.elementary.miscellaneous import Min, Max from sympy.solvers.solveset import solveset from sympy.core.function import diff, Lambda from sympy.series import limit from sympy.calculus.singularities import singularities # TODO...
NotImplementedError
dataset/ETHPy150Open sympy/sympy/sympy/sets/sets.py/Interval._eval_imageset
4,093
def __iter__(self): import itertools # roundrobin recipe taken from itertools documentation: # https://docs.python.org/2/library/itertools.html#recipes def roundrobin(*iterables): "roundrobin('ABC', 'D', 'EF') --> A D E B F C" # Recipe credited to George Sakkis ...
StopIteration
dataset/ETHPy150Open sympy/sympy/sympy/sets/sets.py/Union.__iter__
4,094
def __new__(cls, name, bases, attrs): attrs['base_fields'] = {} declared_fields = {} try: parents = [b for b in bases if issubclass(b, ModelDataset)] parents.reverse() for p in parents: parent_fields = getattr(p, 'base_fields', {}) ...
NameError
dataset/ETHPy150Open joshourisman/django-tablib/django_tablib/models.py/DatasetMetaclass.__new__
4,095
def setUp(self): cs = 10. ncx, ncy, ncz = 10, 10, 10 npad = 4 freq = 1e2 hx = [(cs,npad,-1.3), (cs,ncx), (cs,npad,1.3)] hy = [(cs,npad,-1.3), (cs,ncy), (cs,npad,1.3)] hz = [(cs,npad,-1.3), (cs,ncz), (cs,npad,1.3)] mesh = Mesh.TensorMesh([hx,hy,hz], 'CCC'...
ImportError
dataset/ETHPy150Open simpeg/simpeg/tests/em/fdem/forward/test_FDEM_analytics.py/FDEM_analyticTests.setUp
4,096
def __init__(self, filebasename, mode): self._mode = mode # The directory file is a text file. Each line looks like # "%r, (%d, %d)\n" % (key, pos, siz) # where key is the string key, pos is the offset into the dat # file of the associated value's first byte, and siz is the ...
IOError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/dumbdbm.py/_Database.__init__
4,097
def _update(self): self._index = {} try: f = _open(self._dirfile) except __HOLE__: pass else: for line in f: line = line.rstrip() key, pos_and_siz_pair = eval(line) self._index[key] = pos_and_siz_pair ...
IOError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/dumbdbm.py/_Database._update
4,098
def open(file, flag=None, mode=0666): """Open the database file, filename, and return corresponding object. The flag argument, used to control how the database is opened in the other DBM implementations, is ignored in the dumbdbm module; the database is always opened for update, and will be created if ...
AttributeError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/dumbdbm.py/open
4,099
def find_errors(self, output): """ Convert flow's json output into a set of matches SublimeLinter can process. I'm not sure why find_errors isn't exposed in SublimeLinter's docs, but this would normally attempt to parse a regex and then return a generator full of sanitized match...
ValueError
dataset/ETHPy150Open SublimeLinter/SublimeLinter-flow/linter.py/Flow.find_errors