Unnamed: 0
int64
0
10k
function
stringlengths
79
138k
label
stringclasses
20 values
info
stringlengths
42
261
1,500
def _items(self, req, server_id, entity_maker): """Returns a list of VIFs, transformed through entity_maker.""" context = req.environ['nova.context'] instance = common.get_instance(self.compute_api, context, server_id) try: vifs = self.network_api.get_vifs_by_instance(contex...
NotImplementedError
dataset/ETHPy150Open BU-NU-CLOUD-SP16/Trusted-Platform-Module-nova/nova/api/openstack/compute/legacy_v2/contrib/virtual_interfaces.py/ServerVirtualInterfaceController._items
1,501
def _parse_expires(expires): """ Parse the 'expires' attribute, guessing what format it is in and returning a datetime """ # none is used to signify positive infinity if expires is None or expires in ('never', 'infinity'): return 'infinity' try: return dateutil.parser.parse(...
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/_parse_expires
1,502
def _is_ipv4(self, ip): """ Return true if given arg is a valid IPv4 address """ try: p = IPy.IP(ip) except __HOLE__: return False if p.version() == 4: return True return False
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._is_ipv4
1,503
def _is_ipv6(self, ip): """ Return true if given arg is a valid IPv6 address """ try: p = IPy.IP(ip) except __HOLE__: return False if p.version() == 6: return True return False
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._is_ipv6
1,504
def _get_afi(self, ip): """ Return address-family (4 or 6) for IP or None if invalid address """ parts = unicode(ip).split("/") if len(parts) == 1: # just an address if self._is_ipv4(ip): return 4 elif self._is_ipv6(ip): ...
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._get_afi
1,505
def _get_query_parts(self, query_str, search_options=None): """ Split a query string into its parts """ if search_options is None: search_options = {} if query_str is None: raise NipapValueError("'query_string' must not be None") # find query parts ...
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._get_query_parts
1,506
def _expand_vrf_query(self, query, table_name = None): """ Expand VRF query dict into a WHERE-clause. If you need to prefix each column reference with a table name, that can be supplied via the table_name argument. """ where = str() opt = list() # handl...
KeyError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._expand_vrf_query
1,507
def search_vrf(self, auth, query, search_options=None): """ Search VRF list for VRFs matching `query`. * `auth` [BaseAuth] AAA options. * `query` [dict_to_sql] How the search should be performed. * `search_options` [options_dict] ...
TypeError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.search_vrf
1,508
def _expand_pool_query(self, query, table_name = None): """ Expand pool query dict into a WHERE-clause. If you need to prefix each column reference with a table name, that can be supplied via the table_name argument. """ where = str() opt = list() # han...
KeyError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._expand_pool_query
1,509
def _check_pool_attr(self, attr, req_attr=None): """ Check pool attributes. """ if req_attr is None: req_attr = [] # check attribute names self._check_attr(attr, req_attr, _pool_attrs) # validate IPv4 prefix length if attr.get('ipv4_default_prefix_l...
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._check_pool_attr
1,510
def search_pool(self, auth, query, search_options=None): """ Search pool list for pools matching `query`. * `auth` [BaseAuth] AAA options. * `query` [dict_to_sql] How the search should be performed. * `search_options` [options_dict] ...
TypeError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.search_pool
1,511
def _expand_prefix_query(self, query, table_name = None): """ Expand prefix query dict into a WHERE-clause. If you need to prefix each column reference with a table name, that can be supplied via the table_name argument. """ where = str() opt = list() #...
KeyError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._expand_prefix_query
1,512
def find_free_prefix(self, auth, vrf, args): """ Finds free prefixes in the sources given in `args`. * `auth` [BaseAuth] AAA options. * `vrf` [vrf] Full VRF-dict specifying in which VRF the prefix should be unique. * `args` [fi...
TypeError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.find_free_prefix
1,513
def search_prefix(self, auth, query, search_options=None): """ Search prefix list for prefixes matching `query`. * `auth` [BaseAuth] AAA options. * `query` [dict_to_sql] How the search should be performed. * `search_options` [options_dict] ...
TypeError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.search_prefix
1,514
def _expand_asn_query(self, query, table_name = None): """ Expand ASN query dict into a WHERE-clause. If you need to prefix each column reference with a table name, that can be supplied via the table_name argument. """ where = str() opt = list() # handl...
KeyError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._expand_asn_query
1,515
def search_asn(self, auth, query, search_options=None): """ Search ASNs for entries matching 'query' * `auth` [BaseAuth] AAA options. * `query` [dict_to_sql] How the search should be performed. * `search_options` [options_dict] ...
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.search_asn
1,516
def _parse_asn_query(self, query_str): """ Parse a smart search query for ASNs This is a helper function to smart_search_pool for easier unit testing of the parser. """ # find query parts query_str_parts = self._get_query_parts(query_str) # go through pa...
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._parse_asn_query
1,517
def _expand_tag_query(self, query, table_name = None): """ Expand Tag query dict into a WHERE-clause. If you need to prefix each column reference with a table name, that can be supplied via the table_name argument. """ where = str() opt = list() # handl...
KeyError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap._expand_tag_query
1,518
def search_tag(self, auth, query, search_options=None): """ Search Tags for entries matching 'query' * `auth` [BaseAuth] AAA options. * `query` [dict_to_sql] How the search should be performed. * `search_options` [options_dict] ...
ValueError
dataset/ETHPy150Open SpriteLink/NIPAP/nipap/nipap/backend.py/Nipap.search_tag
1,519
def load_model(path): try: return get_model(path) except __HOLE__: raise ImproperlyConfigured( "{0} must be of the form 'app_label.model_name'".format(path) ) except LookupError: raise ImproperlyConfigured("{0} has not been installed".format(path))
ValueError
dataset/ETHPy150Open haystack/eyebrowse-server/notifications/conf.py/load_model
1,520
def load_path_attr(path): i = path.rfind(".") module, attr = path[:i], path[i + 1:] try: mod = importlib.import_module(module) except __HOLE__ as e: raise ImproperlyConfigured( "Error importing {0}: '{1}'".format(module, e)) try: attr = getattr(mod, attr) exce...
ImportError
dataset/ETHPy150Open haystack/eyebrowse-server/notifications/conf.py/load_path_attr
1,521
def is_installed(package): try: __import__(package) return True except __HOLE__: return False
ImportError
dataset/ETHPy150Open haystack/eyebrowse-server/notifications/conf.py/is_installed
1,522
@property def _ndim(self): try: # From array protocol array = self.context[0][0].__array_interface__ n = array['shape'][1] assert n == 2 or n == 3 return n except __HOLE__: # Fall back on list return len(self.context...
AttributeError
dataset/ETHPy150Open Toblerity/Shapely/shapely/geometry/multipolygon.py/MultiPolygonAdapter._ndim
1,523
def geos_multipolygon_from_polygons(arg): """ ob must be either a MultiPolygon, sequence or array of sequences or arrays. """ if isinstance(arg, MultiPolygon): return geos_geom_from_py(arg) obs = getattr(arg, 'geoms', arg) obs = [ob for ob in obs if ob and not (isin...
TypeError
dataset/ETHPy150Open Toblerity/Shapely/shapely/geometry/multipolygon.py/geos_multipolygon_from_polygons
1,524
def desc(): info = read('README.rst') try: return info + '\n\n' + read('doc/changelog.rst') except __HOLE__: return info # grep flask_admin/__init__.py since python 3.x cannot import it before using 2to3
IOError
dataset/ETHPy150Open flask-admin/flask-admin/setup.py/desc
1,525
def authenticate(email=None, password=None): """ Authenticates the user based on the email field and sets the backend information """ try: backend = EmailBackend() user = backend.authenticate(email=email, password=password) except __HOLE__: # This backend doesn't accept ...
TypeError
dataset/ETHPy150Open jjdelc/django-easy-registration/easyreg/backends.py/authenticate
1,526
def upload_template(filename, destination, context=None, use_jinja=False, template_dir=None, use_sudo=False, backup=True, mirror_local_mode=False, mode=None, pty=None, keep_trailing_newline=False, temp_dir=''): """ Render and upload a template text file to a remote host. Returns the result of the i...
ImportError
dataset/ETHPy150Open fabric/fabric/fabric/contrib/files.py/upload_template
1,527
def _replacer(x): """Replace a number with its hexadecimal representation. Used to tag temporary variables with their calling scope's id. """ # get the hex repr of the binary char and remove 0x and pad by pad_size # zeros try: hexin = ord(x) except __HOLE__: # bytes literals ...
TypeError
dataset/ETHPy150Open pydata/pandas/pandas/computation/scope.py/_replacer
1,528
def resolve(self, key, is_local): """Resolve a variable name in a possibly local context Parameters ---------- key : text_type A variable name is_local : bool Flag indicating whether the variable is local or not (prefixed with the '@' symbol) ...
KeyError
dataset/ETHPy150Open pydata/pandas/pandas/computation/scope.py/Scope.resolve
1,529
def __call__(self, *args, **keywords): if len(args) < 2 or len(args) > 3: raise BadArgument("Start response callback requires either two or three arguments: got %s" % str(args)) if len(args) == 3: exc_info = args[2] try: try: self.h...
TypeError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/modjy/modjy_response.py/start_response_object.__call__
1,530
def check_password(user, raw_password): """Given a DB entry and a raw password, check its validity.""" # Check if the user's password is a "hardened hash". if user.password.startswith('hh$'): alg, salt, bc_pwd = user.password.split('$', 3)[1:] hash = get_hexdigest(alg, salt, raw_password) ...
KeyError
dataset/ETHPy150Open fwenzel/django-sha2/django_sha2/bcrypt_auth.py/check_password
1,531
def get_by_name(self, region, name): """Get one SSH key from a RunAbove account. :param region: Region where the key is :param name: Name of the key to retrieve """ try: region_name = region.name except __HOLE__: region_name = region url =...
AttributeError
dataset/ETHPy150Open runabove/python-runabove/runabove/ssh_key.py/SSHKeyManager.get_by_name
1,532
def create(self, region, name, public_key): """Register a new SSH key in a RunAbove account. :param region: Region where the key will be added :param name: Name of the key :param public_key: Public key value """ try: region_name = region.name except _...
AttributeError
dataset/ETHPy150Open runabove/python-runabove/runabove/ssh_key.py/SSHKeyManager.create
1,533
def delete(self, region, key): """Delete an SSH key from an account. :param region: Region where the key is :param key: SSH key to be deleted """ try: region_name = region.name except AttributeError: region_name = region try: n...
AttributeError
dataset/ETHPy150Open runabove/python-runabove/runabove/ssh_key.py/SSHKeyManager.delete
1,534
def test_dictOfLists(self): args = { 'openid.mode': ['checkid_setup'], 'openid.identity': self.id_url, 'openid.assoc_handle': self.assoc_handle, 'openid.return_to': self.rt_url, 'openid.trust_root': self.tr_url, } try: r...
TypeError
dataset/ETHPy150Open CollabQ/CollabQ/openid/test/test_server.py/TestDecode.test_dictOfLists
1,535
def get_port_spec_info(pipeline, module): type_map = {'OutputPort': 'output', 'InputPort': 'input'} try: type = type_map[module.name] except __HOLE__: raise VistrailsInternalError("cannot translate type '%s'" % module.name) if type == 'input': get_edges = pipeline.graph.edges_fro...
KeyError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/modules/sub_module.py/get_port_spec_info
1,536
def test_events_addons(self): types = { amo.ADDON_ANY: None, amo.ADDON_EXTENSION: 'ADDON', amo.ADDON_THEME: 'THEME', amo.ADDON_DICT: 'DICT', amo.ADDON_SEARCH: 'SEARCH', amo.ADDON_LPAPP: 'LP', amo.ADDON_LPADDON: 'LP', ...
AttributeError
dataset/ETHPy150Open mozilla/addons-server/src/olympia/editors/tests/test_models.py/TestReviewerScore.test_events_addons
1,537
def render(engine, format, filepath): """Render file with Graphviz engine into format, return result filename. Args: engine: The layout commmand used for rendering ('dot', 'neato', ...). format: The output format used for rendering ('pdf', 'png', ...). filepath: Path to the DOT source ...
OSError
dataset/ETHPy150Open xflr6/graphviz/graphviz/backend.py/render
1,538
def pipe(engine, format, data): """Return data piped through Graphviz engine into format. Args: engine: The layout commmand used for rendering ('dot', 'neato', ...) format: The output format used for rendering ('pdf', 'png', ...) data: The binary (encoded) DOT source string to render. ...
OSError
dataset/ETHPy150Open xflr6/graphviz/graphviz/backend.py/pipe
1,539
def ProcessBackendNode(self, node): """Processes XML nodes labeled 'backend' into a Backends object.""" tag = xml_parser_utils.GetTag(node) if tag != 'backend': self.errors.append('Unrecognized node: <%s>' % tag) return backend = Backend() name = xml_parser_utils.GetAttribute(node, 'nam...
ValueError
dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/tools/backends_xml_parser.py/BackendsXmlParser.ProcessBackendNode
1,540
def _format_date(d): try: return d.strftime('%d-%m-%Y') except __HOLE__: return d
AttributeError
dataset/ETHPy150Open dimagi/commcare-hq/custom/bihar/reports/indicators/display.py/_format_date
1,541
def pop(queue, quantity=1): ''' Pop one or more or all items from the queue return them. ''' cmd = 'SELECT name FROM {0}'.format(queue) if quantity != 'all': try: quantity = int(quantity) except __HOLE__ as exc: error_txt = ('Quantity must be an integer or "al...
ValueError
dataset/ETHPy150Open saltstack/salt/salt/queues/sqlite_queue.py/pop
1,542
def __virtual__(): ''' Only work on systems that are a proxy minion ''' try: if salt.utils.is_proxy() and __opts__['proxy']['proxytype'] == 'rest_sample': return __virtualname__ except __HOLE__: return (False, 'The rest_service execution module failed to load. Check the ...
KeyError
dataset/ETHPy150Open saltstack/salt/salt/modules/rest_service.py/__virtual__
1,543
def isStr(s): t = '' try: t += s except __HOLE__: return 0 return 1
TypeError
dataset/ETHPy150Open cloudera/hue/desktop/core/ext-py/pycrypto-2.6.1/lib/Crypto/SelfTest/Signature/test_pkcs1_pss.py/isStr
1,544
def __getattr__(self, attr): if attr in self._fields: return self._fields[attr].get() for conditional_field in self._conditional_fields: try: return getattr(conditional_field, attr) except __HOLE__: pass # pragma: no cover ...
AttributeError
dataset/ETHPy150Open alexras/bread/bread/struct.py/BreadStruct.__getattr__
1,545
def __setattr__(self, attr, value): try: if attr[0] == '_': super(BreadStruct, self).__setattr__(attr, value) elif attr in self._fields: field = self._fields[attr] field.set(value) else: for conditional_field in ...
AttributeError
dataset/ETHPy150Open alexras/bread/bread/struct.py/BreadStruct.__setattr__
1,546
def extractFromBinary(self,binaryImg,colorImg, minsize = 5, maxsize = -1,appx_level=3): """ This method performs blob extraction given a binary source image that is used to get the blob images, and a color source image. binarymg- The binary image with the blobs. colorImg - The co...
RuntimeError
dataset/ETHPy150Open sightmachine/SimpleCV/SimpleCV/Features/BlobMaker.py/BlobMaker.extractFromBinary
1,547
def get_token_from_authorization(self, authorization): try: scheme, token = authorization.split() except __HOLE__: raise ApiError(401, {'code': 'invalid_authorization'}) if scheme != 'Bearer': raise ApiError(401, {'code': 'invalid_authorization.scheme'}) ...
ValueError
dataset/ETHPy150Open 4Catalyzer/flask-resty/flask_resty/jwt.py/JwtAuthentication.get_token_from_authorization
1,548
def get_page(self, object_list): ''' Return a paginated object list, along with some metadata If self.page_size is not None, pagination is enabled. The page_size can be overridden by passing it in the requst, but it is limited to 1 < page_size < max_page_size. max_page...
ValueError
dataset/ETHPy150Open funkybob/django-nap/nap/rest/publisher.py/Publisher.get_page
1,549
@verbose def export_volume(self, fname, include_surfaces=True, include_discrete=True, dest='mri', trans=None, mri_resolution=False, use_lut=True, verbose=None): """Exports source spaces to nifti or mgz file Parameters ---------- fname : st...
ImportError
dataset/ETHPy150Open mne-tools/mne-python/mne/source_space.py/SourceSpaces.export_volume
1,550
@verbose def setup_volume_source_space(subject, fname=None, pos=5.0, mri=None, sphere=(0.0, 0.0, 0.0, 90.0), bem=None, surface=None, mindist=5.0, exclude=0.0, overwrite=False, subjects_dir=None, volum...
ValueError
dataset/ETHPy150Open mne-tools/mne-python/mne/source_space.py/setup_volume_source_space
1,551
def _make_volume_source_space(surf, grid, exclude, mindist, mri=None, volume_label=None, do_neighbors=True, n_jobs=1): """Make a source space which covers the volume bounded by surf""" # Figure out the grid size in the MRI coordinate frame mins = np.min(surf['rr'], axis=0) ...
ImportError
dataset/ETHPy150Open mne-tools/mne-python/mne/source_space.py/_make_volume_source_space
1,552
def _get_mri_header(fname): """Get MRI header using nibabel""" import nibabel as nib img = nib.load(fname) try: return img.header except __HOLE__: # old nibabel return img.get_header()
AttributeError
dataset/ETHPy150Open mne-tools/mne-python/mne/source_space.py/_get_mri_header
1,553
@verbose def add_source_space_distances(src, dist_limit=np.inf, n_jobs=1, verbose=None): """Compute inter-source distances along the cortical surface This function will also try to add patch info for the source space. It will only occur if the ``dist_limit`` is sufficiently high that all points on the ...
TypeError
dataset/ETHPy150Open mne-tools/mne-python/mne/source_space.py/add_source_space_distances
1,554
def connect_job(job_id, deployment_name, token_manager=None, app_url=defaults.APP_URL, persist=False, websocket=None, data_url=None): """ connect to a running Juttle program by job_id """ if data_url == Non...
IOError
dataset/ETHPy150Open jut-io/jut-python-tools/jut/api/data_engine.py/connect_job
1,555
def http_assembler(PCAP): print "[*] Loading PCAP file..." p = rdpcap(PCAP) print "[*] Loading sessions..." sessions = p.sessions() for session in sessions: http_payload = '' for packet in sessions[session]: try: if packet[TCP].dport == 80 or packet[TCP].s...
OSError
dataset/ETHPy150Open mertsarica/hack4career/codes/eval-finder.py/http_assembler
1,556
def _get_timeout(self, timeout): try: tout = utils.secs_to_timestr(utils.timestr_to_secs(timeout.string)) except __HOLE__: tout = timeout.string if timeout.message: tout += ' :: ' + timeout.message return tout
ValueError
dataset/ETHPy150Open shellderp/sublime-robot-plugin/lib/robot/testdoc.py/JsonConverter._get_timeout
1,557
def to_dicts(collection, key=None, **kw): _dicts = [] try: for each in collection: try: each_dict = each.to_dict(**kw) if key: each_dict = key(each_dict) _dicts.append(each_dict) except __HOLE__: ...
AttributeError
dataset/ETHPy150Open ramses-tech/nefertari/nefertari/utils/data.py/to_dicts
1,558
def sequential_id(self, uuid): if self.sequence is not None: return self.sequence.sequential_id(uuid) try: return int(uuid) except (ValueError, __HOLE__): raise ValueError("A `Sequence` instance is required " "to use non integer uu...
TypeError
dataset/ETHPy150Open caxap/redis-moment/moment/bitevents.py/Event.sequential_id
1,559
def test_DnfInstaller(): from rosdep2.platforms.redhat import DnfInstaller @patch.object(DnfInstaller, 'get_packages_to_install') def test(mock_method): installer = DnfInstaller() mock_method.return_value = [] assert [] == installer.get_install_command(['fake']) # no intera...
AssertionError
dataset/ETHPy150Open ros-infrastructure/rosdep/test/test_rosdep_redhat.py/test_DnfInstaller
1,560
def test_YumInstaller(): from rosdep2.platforms.redhat import YumInstaller @patch.object(YumInstaller, 'get_packages_to_install') def test(mock_method): installer = YumInstaller() mock_method.return_value = [] assert [] == installer.get_install_command(['fake']) # no intera...
AssertionError
dataset/ETHPy150Open ros-infrastructure/rosdep/test/test_rosdep_redhat.py/test_YumInstaller
1,561
@classmethod def parse_float(cls, string): # {{{ for bad_char in ['$', ',', '%']: string = string.replace(bad_char, '') try: return float(string) except __HOLE__: return None
ValueError
dataset/ETHPy150Open mrooney/mintapi/mintapi/api.py/Mint.parse_float
1,562
def login_and_get_token(self, email, password): # {{{ # 0: Check to see if we're already logged in. if self.token is not None: return # 1: Login. login_url = 'https://wwws.mint.com/login.event?task=L' try: self.request_and_check(login_url) except...
RuntimeError
dataset/ETHPy150Open mrooney/mintapi/mintapi/api.py/Mint.login_and_get_token
1,563
def get_accounts(self, get_detail=False): # {{{ # Issue service request. req_id = str(self.request_id) input = { 'args': { 'types': [ 'BANK', 'CREDIT', 'INVESTMENT', 'LOAN', ...
TypeError
dataset/ETHPy150Open mrooney/mintapi/mintapi/api.py/Mint.get_accounts
1,564
def get_net_worth(self, account_data=None): if account_data is None: account_data = self.get_accounts() # account types in this list will be subtracted negative_accounts = ['loan', 'loans', 'credit'] try: net_worth = long() except __HOLE__: ne...
NameError
dataset/ETHPy150Open mrooney/mintapi/mintapi/api.py/Mint.get_net_worth
1,565
def main(): import getpass import argparse try: import keyring except __HOLE__: keyring = None # Parse command-line arguments {{{ cmdline = argparse.ArgumentParser() cmdline.add_argument('email', nargs='?', default=None, help='The e-mail address for...
ImportError
dataset/ETHPy150Open mrooney/mintapi/mintapi/api.py/main
1,566
def is_dateutil_result_obj_parsed(date_string): # handle dateutil>=2.5 tuple result first try: res, _ = parser()._parse(date_string) except __HOLE__: res = parser()._parse(date_string) if not res: return False def get_value(obj, key): value = getattr(obj, key) ...
TypeError
dataset/ETHPy150Open scrapinghub/dateparser/dateparser/utils/__init__.py/is_dateutil_result_obj_parsed
1,567
def close(self): """ Clean up resources after use. Note that the instance is no longer readable nor writable after calling close(). The method is automatically called by garbage collectors, but made public to allow explicit cleanup. """ if self._closefile...
IOError
dataset/ETHPy150Open twoolie/NBT/nbt/region.py/RegionFile.close
1,568
def _parse_chunk_headers(self): for x in range(32): for z in range(32): m = self.metadata[x, z] if m.status not in (STATUS_CHUNK_OK, STATUS_CHUNK_OVERLAPPING, \ STATUS_CHUNK_MISMATCHED_LENGTHS): # skip to next if...
IOError
dataset/ETHPy150Open twoolie/NBT/nbt/region.py/RegionFile._parse_chunk_headers
1,569
def password_callback(v, prompt1='Enter private key passphrase:', prompt2='Verify passphrase:'): from getpass import getpass while 1: try: p1=getpass(prompt1) if v: p2=getpass(prompt2) if p1==p2: break...
KeyboardInterrupt
dataset/ETHPy150Open CollabQ/CollabQ/vendor/gdata/tlslite/utils/OpenSSL_RSAKey.py/password_callback
1,570
@staticmethod def ensureIsWorkingDirectory(path): """ Ensure that C{path} is a Git working directory. @type path: L{twisted.python.filepath.FilePath} @param path: The path to check. """ try: runCommand(["git", "rev-parse"], cwd=path.path) except (...
OSError
dataset/ETHPy150Open twisted/twisted/twisted/python/_release.py/GitCommand.ensureIsWorkingDirectory
1,571
def getRepositoryCommand(directory): """ Detect the VCS used in the specified directory and return either a L{SVNCommand} or a L{GitCommand} if the directory is a Subversion checkout or a Git repository, respectively. If the directory is neither one nor the other, it raises a L{NotWorkingDirecto...
OSError
dataset/ETHPy150Open twisted/twisted/twisted/python/_release.py/getRepositoryCommand
1,572
def _create_new_file(self, path): attempt_open = True try: self.create(path) except __HOLE__ as e: attempt_open = False sublime.error_message("Cannot create '" + path + "'. See console for details") return attempt_ope...
OSError
dataset/ETHPy150Open skuroda/Sublime-AdvancedNewFile/advanced_new_file/commands/cut_to_file.py/AdvancedNewFileCutToFile._create_new_file
1,573
def import_packages_module(self): """Imports the 'vistrails.packages' package. This might need to manipulate the Python path to find it. """ if self._packages is not None: return self._packages # Imports standard packages directory conf = self._startup.temp_c...
ImportError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/packagemanager.py/PackageManager.import_packages_module
1,574
def import_user_packages_module(self): """Imports the 'userspackages' package. This will need to manipulate the Python path to find it. """ if self._userpackages is not None: return self._userpackages # Imports user packages directory old_sys_path = copy.copy...
ImportError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/packagemanager.py/PackageManager.import_user_packages_module
1,575
def __init__(self, registry, startup): global _package_manager if _package_manager: m = "Package manager can only be constructed once." raise VistrailsInternalError(m) _package_manager = self self._registry = registry self._startup = startup # Co...
KeyError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/packagemanager.py/PackageManager.__init__
1,576
def _import_override(self, name, globals={}, locals={}, fromlist=[], level=-1): """Overridden __import__ function. This replaces the builtin __import__ function globally so that we can track imports done from a package. This is recorded in the Package so that re...
KeyError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/packagemanager.py/PackageManager._import_override
1,577
def get_available_package(self, codepath, prefix=None): try: pkg = self._available_packages[codepath] except __HOLE__: pkg = self._registry.create_package(codepath, prefix=prefix) self._available_packages[codepath] = pkg pkg.persistent_configuration = \ ...
KeyError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/packagemanager.py/PackageManager.get_available_package
1,578
def get_package(self, identifier, version=None): # check if it's an old identifier identifier = self._old_identifier_map.get(identifier, identifier) try: package_versions = self._package_versions[identifier] if version is not None: return package_versions[...
KeyError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/packagemanager.py/PackageManager.get_package
1,579
def build_available_package_names_list(self): def is_vistrails_package(path): if os.path.isfile(path): return (path.endswith('.py') and not path.endswith('__init__.py')) elif os.path.isdir(path): return os.path.isfile(os.path.join(p...
ImportError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/core/packagemanager.py/PackageManager.build_available_package_names_list
1,580
def is_idx(index): """Checks if an object can work as an index or not.""" if type(index) in six.integer_types: return True elif hasattr(index, "__index__"): # Only works on Python 2.5 (PEP 357) # Exclude the array([idx]) as working as an index. Fixes #303. if (hasattr(index, "shap...
TypeError
dataset/ETHPy150Open PyTables/PyTables/tables/utils.py/is_idx
1,581
def tearDown(self): try: os.unlink(FILENAME) except __HOLE__: pass
OSError
dataset/ETHPy150Open google/oauth2client/tests/test_file.py/OAuth2ClientFileTests.tearDown
1,582
def setUp(self): try: os.unlink(FILENAME) except __HOLE__: pass
OSError
dataset/ETHPy150Open google/oauth2client/tests/test_file.py/OAuth2ClientFileTests.setUp
1,583
def render(self, name, value, attrs=None, choices=()): try: value = {True: u'2', False: u'3', u'2': u'2', u'3': u'3'}[value] except __HOLE__: value = u'1' return super(NullBooleanSelect, self).render(name, value, attrs, choices)
KeyError
dataset/ETHPy150Open CollabQ/CollabQ/vendor/django/forms/widgets.py/NullBooleanSelect.render
1,584
def render(self, name, value, attrs=None): # value is a list of values, each corresponding to a widget # in self.widgets. if not isinstance(value, list): value = self.decompress(value) output = [] final_attrs = self.build_attrs(attrs) id_ = final_attrs.get('id...
IndexError
dataset/ETHPy150Open CollabQ/CollabQ/vendor/django/forms/widgets.py/MultiWidget.render
1,585
def main(): """Launch the API server.""" # Parse command line options if present. tornado.options.parse_command_line() options = tornado.options.options # Bring in (server-wide) configuration information. try: import configparser # Python 3.0 except __HOLE__: import ...
ImportError
dataset/ETHPy150Open MapQuest/mapquest-osm-server/src/python/frontend/__main__.py/main
1,586
def __init__(self, skeleton, savefile_name, skin=False): super(BoneUILayer, self).__init__() self.user_skin = skin self.count = 0 self.savefile_name = savefile_name try: self.animation = pickle.load( open(savefile_name, "rb") ) except __HOLE__: sel...
IOError
dataset/ETHPy150Open los-cocos/cocos/tools/skeleton/animator.py/BoneUILayer.__init__
1,587
def bind_api(**config): class APIMethod(object): api = config['api'] path = config['path'] payload_type = config.get('payload_type', None) payload_list = config.get('payload_list', False) allowed_param = config.get('allowed_param', []) method = config.get('method', ...
IndexError
dataset/ETHPy150Open tweepy/tweepy/tweepy/binder.py/bind_api
1,588
@_git_check def last_checked_for_updates(gitrepo): """ Find out the last time plugins were checked for updates. :param string gitrepo: path to the initialized Git repository :returns: Unix timestamp the last time it was checked, ``0`` if this is the first time. """ retval = 0 confi...
ValueError
dataset/ETHPy150Open robmadole/jig/src/jig/plugins/tools.py/last_checked_for_updates
1,589
def reload_request(self, locator, index=None): self.web_element_reload = True try: # element was found out via find_elements if index is not None: web_els = self.src_element.find_elements(*locator) web_el = web_els[index] else: ...
IndexError
dataset/ETHPy150Open CiscoSystems/avos/openstack_dashboard/test/integration_tests/webdriver.py/WebElementWrapper.reload_request
1,590
def reload_request(self, locator, index): try: # element was found out via find_elements if index is not None: web_els = self.find_elements(*locator) web_el = web_els[index] else: web_el = self.find_element(*locator) ...
IndexError
dataset/ETHPy150Open CiscoSystems/avos/openstack_dashboard/test/integration_tests/webdriver.py/WebDriverWrapper.reload_request
1,591
def _emit(self, record, **kwargs): data = {} extra = getattr(record, 'data', None) if not isinstance(extra, dict): if extra: extra = {'data': extra} else: extra = {} for k, v in iteritems(vars(record)): if k in RESERVE...
UnicodeDecodeError
dataset/ETHPy150Open getsentry/raven-python/raven/handlers/logging.py/SentryHandler._emit
1,592
def run_only_if_gearman_is_available(func): try: import gearman except __HOLE__: gearman = None pred = lambda: gearman is not None return run_only(func, pred)
ImportError
dataset/ETHPy150Open Yelp/fullerite/src/diamond/collectors/gearman_stats/test/testgearmanstats.py/run_only_if_gearman_is_available
1,593
def handle(self, *args, **options): verbosity = int(options.get('verbosity', 1)) depth = int(options.get('depth', 3)) auth = _parse_auth(options.get('auth')) if verbosity > 1: log_level = logging.DEBUG elif verbosity: log_level = logging.INFO els...
ImportError
dataset/ETHPy150Open ericholscher/django-test-utils/test_utils/management/commands/crawlurls.py/Command.handle
1,594
def compute(self): left_t = self.get_input('left_table') right_t = self.get_input('right_table') case_sensitive = self.get_input('case_sensitive') always_prefix = self.get_input('always_prefix') def get_column_idx(table, prefix): col_name_port = "%s_column_name" % pr...
ValueError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/packages/tabledata/operations.py/JoinTables.compute
1,595
def compute(self): table = self.get_input("table") try: indexes = choose_columns( table.columns, column_names=table.names, names=self.force_get_input('column_names', None), indexes=self.force_get_input('column_in...
ValueError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/packages/tabledata/operations.py/ProjectTable.compute
1,596
def compute(self): table = self.get_input('table') if self.has_input('str_expr'): (col, comparer, comparand) = self.get_input('str_expr') elif self.has_input('float_expr'): (col, comparer, comparand) = self.get_input('float_expr') else: raise ModuleEr...
ValueError
dataset/ETHPy150Open VisTrails/VisTrails/vistrails/packages/tabledata/operations.py/SelectFromTable.compute
1,597
def parseInfo(self, attributes, line=None): ''' Parse the attributes line of an entry, line parameter provided purely for backwards compatability''' # remove comments attributes = attributes.split("#")[0] # separate into fields fields = map(lambda x: x.strip(), attribute...
ValueError
dataset/ETHPy150Open CGATOxford/cgat/CGAT/GFF3.py/Entry.parseInfo
1,598
def action(self): """ This class overrides this method """ commandline = "{0} {1}".format(self.command, " ".join(self.arguments)) try: completed_process = subprocess.run(commandline, shell=True) self.exit_status = completed_process.returncode excep...
AttributeError
dataset/ETHPy150Open pmbarrett314/curses-menu/cursesmenu/items/command_item.py/CommandItem.action
1,599
def _randrange(seed=None): """Return a randrange generator. ``seed`` can be o None - return randomly seeded generator o int - return a generator seeded with the int o list - the values to be returned will be taken from the list in the order given; the provided list is not modified....
AttributeError
dataset/ETHPy150Open sympy/sympy/sympy/utilities/randtest.py/_randrange