Unnamed: 0
int64
0
10k
function
stringlengths
79
138k
label
stringclasses
20 values
info
stringlengths
42
261
3,400
@classdef.method("atime") def method_atime(self, space): try: stat_val = os.stat(self.filename) except __HOLE__ as e: raise error_for_oserror(space, e) return self._time_at(space, stat_val.st_atime)
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.method_atime
3,401
@classdef.method("ctime") def method_ctime(self, space): try: stat_val = os.stat(self.filename) except __HOLE__ as e: raise error_for_oserror(space, e) return self._time_at(space, stat_val.st_ctime)
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.method_ctime
3,402
@classdef.method("chmod", mode="int") def method_chmod(self, space, mode): try: fchmod(self.fd, mode) except __HOLE__ as e: raise error_for_oserror(space, e) return space.newint(0)
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.method_chmod
3,403
@classdef.singleton_method("chmod", mode="int") def singleton_method_chmod(self, space, mode, args_w): for arg_w in args_w: path = Coerce.path(space, arg_w) try: os.chmod(path, mode) except __HOLE__ as e: raise error_for_oserror(space, e) ...
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.singleton_method_chmod
3,404
@classdef.singleton_method("stat", filename="path") def singleton_method_stat(self, space, filename): try: stat_val = os.stat(filename) except __HOLE__ as e: raise error_for_oserror(space, e) stat_obj = W_FileStatObject(space) stat_obj.set_stat(stat_val) ...
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.singleton_method_stat
3,405
@classdef.singleton_method("lstat", filename="path") def singleton_method_lstat(self, space, filename): try: stat_val = os.lstat(filename) except __HOLE__ as e: raise error_for_oserror(space, e) stat_obj = W_FileStatObject(space) stat_obj.set_stat(stat_val) ...
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.singleton_method_lstat
3,406
@classdef.singleton_method("symlink", old_name="path", new_name="path") def singleton_method_symlink(self, space, old_name, new_name): try: os.symlink(old_name, new_name) except __HOLE__ as e: raise error_for_oserror(space, e) return space.newi...
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.singleton_method_symlink
3,407
@classdef.singleton_method("link", old_name="path", new_name="path") def singleton_method_link(self, space, old_name, new_name): try: os.link(old_name, new_name) except __HOLE__ as e: raise error_for_oserror(space, e) return space.newint(0)
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileObject.singleton_method_link
3,408
@classdef.method("initialize", filename="path") def method_initialize(self, space, filename): try: self.set_stat(os.stat(filename)) except __HOLE__ as e: raise error_for_oserror(space, e)
OSError
dataset/ETHPy150Open topazproject/topaz/topaz/objects/fileobject.py/W_FileStatObject.method_initialize
3,409
def update_address_book(self, user, shipping_addr): """ Update the user's address book based on the new shipping address """ try: user_addr = user.addresses.get( hash=shipping_addr.generate_hash()) except __HOLE__: # Create a new user addre...
ObjectDoesNotExist
dataset/ETHPy150Open django-oscar/django-oscar/src/oscar/apps/checkout/mixins.py/OrderPlacementMixin.update_address_book
3,410
def test_prevent_configuring_two_storages_with_same_name(self): DepotManager.configure('first', {'depot.storage_path': './lfs'}) try: DepotManager.configure('first', {'depot.storage_path': './lfs2'}) except __HOLE__: pass else: assert False, 'Should h...
RuntimeError
dataset/ETHPy150Open amol-/depot/tests/test_depot_manager.py/TestDepotManager.test_prevent_configuring_two_storages_with_same_name
3,411
def readFile(self): ''' Read the data from the file specified in the global object path. The data readed is encoded with the format specified in the global object encoding, by default this object is UTF-8. Use this method if you don't want to modify the data received from the fil...
IOError
dataset/ETHPy150Open gepd/Deviot/libs/JSONFile.py/JSONFile.readFile
3,412
def writeFile(self, text, append=False): '''Write File Write the data passed in a file specified in the global object path. This method is called automatically by saveData, and encode the text in the format specified in the global object encoding, by default this object is UTF-8...
IOError
dataset/ETHPy150Open gepd/Deviot/libs/JSONFile.py/JSONFile.writeFile
3,413
def display_for_field(value, field, empty_value_display=None): try: return _display_for_field(value, field, empty_value_display) except __HOLE__: return _display_for_field(value, field)
TypeError
dataset/ETHPy150Open callowayproject/django-categories/categories/editor/utils.py/display_for_field
3,414
def lower(self, key): try: return key.lower() except __HOLE__: return key
AttributeError
dataset/ETHPy150Open ejeschke/ginga/ginga/misc/Bunch.py/caselessDict.lower
3,415
def _votes(self, val): """ Returns cleaned version of votes or 0 if it's a non-numeric value. """ if type(val) is str: if val.strip() == '': return 0 try: return int(float(val)) except __HOLE__: # Count'y convert value ...
ValueError
dataset/ETHPy150Open openelections/openelections-core/openelex/us/nh/load.py/NHBaseLoader._votes
3,416
def test_unique_for_date_with_nullable_date(self): FlexibleDatePost.objects.create( title="Django 1.0 is released", slug="Django 1.0", subtitle="Finally", posted=datetime.date(2008, 9, 3), ) p = FlexibleDatePost(title="Django 1.0 is released") try: p.f...
ValidationError
dataset/ETHPy150Open django/django/tests/validation/test_unique.py/PerformUniqueChecksTest.test_unique_for_date_with_nullable_date
3,417
def validate(self): """ Validate pidfile and make it stale if needed""" if not self.fname: return try: with open(self.fname, "r") as f: wpid = int(f.read() or 0) if wpid <= 0: return try: ...
IOError
dataset/ETHPy150Open benoitc/tproxy/tproxy/pidfile.py/Pidfile.validate
3,418
def main(): with CementDevtoolsApp() as app: try: app.run() except __HOLE__ as e: print("AssertionError => %s" % e.args[0])
AssertionError
dataset/ETHPy150Open datafolklabs/cement/scripts/devtools.py/main
3,419
def __str__(self): """Prints string with field name if present on exception.""" message = Error.__str__(self) try: field_name = self.field_name except __HOLE__: return message else: return message # Attributes that are reserved by a class definition that # may not be used by eith...
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/ValidationError.__str__
3,420
def message_definition(cls): """Get outer Message definition that contains this definition. Returns: Containing Message definition if definition is contained within one, else None. """ try: return cls._message_definition() except __HOLE__: return None
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/_DefinitionClass.message_definition
3,421
def __new__(cls, index): """Acts as look-up routine after class is initialized. The purpose of overriding __new__ is to provide a way to treat Enum subclasses as casting types, similar to how the int type functions. A program can pass a string or an integer and this method with "convert" that valu...
KeyError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Enum.__new__
3,422
def check_initialized(self): """Check class for initialization status. Check that all required fields are initialized Raises: ValidationError: If message is not initialized. """ for name, field in self.__by_name.iteritems(): value = getattr(self, name) if value is None: i...
ValidationError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Message.check_initialized
3,423
def is_initialized(self): """Get initialization status. Returns: True if message is valid, else False. """ try: self.check_initialized() except __HOLE__: return False else: return True
ValidationError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Message.is_initialized
3,424
def get_assigned_value(self, name): """Get the assigned value of an attribute. Get the underlying value of an attribute. If value has not been set, will not return the default for the field. Args: name: Name of attribute to get. Returns: Value of attribute, None if it has not been se...
KeyError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Message.get_assigned_value
3,425
def reset(self, name): """Reset assigned value for field. Resetting a field will return it to its default value or None. Args: name: Name of field to reset. """ message_type = type(self) try: field = message_type.field_by_name(name) except __HOLE__: if name not in message...
KeyError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Message.reset
3,426
@util.positional(2) def __init__(self, number, required=False, repeated=False, variant=None, default=None): """Constructor. The required and repeated parameters are mutually exclusive. Setting both to True will raise a FieldDefin...
ValidationError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Field.__init__
3,427
def validate_element(self, value): """Validate single element of field. This is different from validate in that it is used on individual values of repeated fields. Args: value: Value to validate. Raises: ValidationError if value is not expected type. """ if not isinstance(valu...
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Field.validate_element
3,428
def __validate(self, value, validate_element): """Internal validation function. Validate an internal value using a function to validate individual elements. Args: value: Value to validate. validate_element: Function to use to validate individual elements. Raises: ValidationError if ...
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Field.__validate
3,429
def message_definition(self): """Get Message definition that contains this Field definition. Returns: Containing Message definition for Field. Will return None if for some reason Field is defined outside of a Message class. """ try: return self._message_definition() except __HOLE...
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/Field.message_definition
3,430
def validate_element(self, value): """Validate StringField allowing for str and unicode. Raises: ValidationError if a str value is not 7-bit ascii. """ # If value is str is it considered valid. Satisfies "required=True". if isinstance(value, str): try: unicode(value) exce...
UnicodeDecodeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/StringField.validate_element
3,431
@property def default(self): """Default for enum field. Will cause resolution of Enum type and unresolved default value. """ try: return self.__resolved_default except __HOLE__: resolved_default = super(EnumField, self).default if isinstance(resolved_default, (basestring, int, l...
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/EnumField.default
3,432
@util.positional(2) def find_definition(name, relative_to=None, importer=__import__): """Find definition by name in module-space. The find algorthm will look for definitions by name relative to a message definition or by fully qualfied name. If no definition is found relative to the relative_to parameter it w...
ImportError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/protorpc/protorpc/messages.py/find_definition
3,433
def test_lists_plus_nonlists(self): def f(): try: return [] + 10 except __HOLE__: return None self.equivalentEvaluationTestThatHandlesExceptions(f)
TypeError
dataset/ETHPy150Open ufora/ufora/ufora/FORA/python/PurePython/ListTestCases.py/ListTestCases.test_lists_plus_nonlists
3,434
def safe_input(): '''Prompts the user for an integer and return only when a valid value is entered ''' while True: try: guess = int(input(prompt)) return guess except __HOLE__: print("You must enter a valid value.")
ValueError
dataset/ETHPy150Open aroberge/pyproj/guess_number/guess_2.py/safe_input
3,435
def _cachedfunc(cache, makekey, lock): def decorator(func): stats = [0, 0] def wrapper(*args, **kwargs): key = makekey(args, kwargs) with lock: try: result = cache[key] stats[0] += 1 return result ...
KeyError
dataset/ETHPy150Open PressLabs/gitfs/gitfs/cache/decorators/lru.py/_cachedfunc
3,436
def parse_payload(payload): if not isinstance(payload, str): payload = ' '.join(payload) try: json.loads(payload) except __HOLE__: kv = payload.split(' ', 1) if len(kv) > 1: payload = '{"%s": "%s"}' % (kv[0], kv[1]) else: payload = '%s' % kv[0] ...
ValueError
dataset/ETHPy150Open 46elks/elkme/elkme/helpers.py/parse_payload
3,437
def test_bad_pack(self): try: session = ss.Session(pack=_bad_packer) except __HOLE__ as e: self.assertIn("could not serialize", str(e)) self.assertIn("don't work", str(e)) else: self.fail("Should have raised ValueError")
ValueError
dataset/ETHPy150Open jupyter/jupyter_client/jupyter_client/tests/test_session.py/TestSession.test_bad_pack
3,438
def test_bad_unpack(self): try: session = ss.Session(unpack=_bad_unpacker) except __HOLE__ as e: self.assertIn("could not handle output", str(e)) self.assertIn("don't work either", str(e)) else: self.fail("Should have raised ValueError")
ValueError
dataset/ETHPy150Open jupyter/jupyter_client/jupyter_client/tests/test_session.py/TestSession.test_bad_unpack
3,439
def test_bad_packer(self): try: session = ss.Session(packer=__name__ + '._bad_packer') except __HOLE__ as e: self.assertIn("could not serialize", str(e)) self.assertIn("don't work", str(e)) else: self.fail("Should have raised ValueError")
ValueError
dataset/ETHPy150Open jupyter/jupyter_client/jupyter_client/tests/test_session.py/TestSession.test_bad_packer
3,440
def test_bad_unpacker(self): try: session = ss.Session(unpacker=__name__ + '._bad_unpacker') except __HOLE__ as e: self.assertIn("could not handle output", str(e)) self.assertIn("don't work either", str(e)) else: self.fail("Should have raised Value...
ValueError
dataset/ETHPy150Open jupyter/jupyter_client/jupyter_client/tests/test_session.py/TestSession.test_bad_unpacker
3,441
def to_string(s): """Convert ``bytes`` to ``str``, leaving ``unicode`` unchanged. (This means on Python 2, ``to_string()`` does nothing.) Use this if you need to ``print()`` or log bytes of an unknown encoding, or to parse strings out of bytes of unknown encoding (e.g. a log file). """ if not ...
UnicodeDecodeError
dataset/ETHPy150Open Yelp/mrjob/mrjob/py2.py/to_string
3,442
def call_and_wait_tool(command, tool_name, input = '', on_result = None, filename = None, on_line = None, check_enabled = True, **popen_kwargs): tool_enabled = 'enable_{0}'.format(tool_name) if check_enabled and get_setting_async(tool_enabled) != True: return None extended_env = get_extended_env() ...
OSError
dataset/ETHPy150Open SublimeHaskell/SublimeHaskell/sublime_haskell_common.py/call_and_wait_tool
3,443
def call_ghcmod_and_wait(arg_list, filename=None, cabal = None): """ Calls ghc-mod with the given arguments. Shows a sublime error message if ghc-mod is not available. """ ghc_opts_args = get_ghc_opts_args(filename, add_package_db = False, cabal = cabal) try: command = ['ghc-mod'] + gh...
OSError
dataset/ETHPy150Open SublimeHaskell/SublimeHaskell/sublime_haskell_common.py/call_ghcmod_and_wait
3,444
def _wrapped_operation(exc_class): def decorator(fn): def inner(*args, **kwargs): try: return fn(*args, **kwargs) except (KeyboardInterrupt, __HOLE__): raise except: wrap_exception(exc_class) ...
RuntimeError
dataset/ETHPy150Open coleifer/huey/huey/api.py/Huey._wrapped_operation
3,445
def block_collapse(expr): """Evaluates a block matrix expression >>> from sympy import MatrixSymbol, BlockMatrix, symbols, \ Identity, Matrix, ZeroMatrix, block_collapse >>> n,m,l = symbols('n m l') >>> X = MatrixSymbol('X', n, n) >>> Y = MatrixSymbol('Y', m ,m) >>> Z ...
AttributeError
dataset/ETHPy150Open sympy/sympy/sympy/matrices/expressions/blockmatrix.py/block_collapse
3,446
def run(self): # Get config file location s = sublime.load_settings("WordPressDev.sublime-settings") config_file_location = s.get("wp_config_file") try: # Open up config file with open(config_file_location, 'r') as wp_config: pass windo...
IOError
dataset/ETHPy150Open huntlyc/Sublime-Wordpress-Dev-Plugin/wordpress_dev.py/WordpressOpenConfigCommand.run
3,447
def extract_wp_db_defs(self): db_names = [] try: with open(self.config_file_location, 'r') as wp_config: file_contents = wp_config.read() wp_config.close() # DB's are defined as define('DB_NAME', 'wp_default'); repatt = '(?:\/\/)...
IOError
dataset/ETHPy150Open huntlyc/Sublime-Wordpress-Dev-Plugin/wordpress_dev.py/WordpressDbSwitcherCommand.extract_wp_db_defs
3,448
def switch_active_database(self, dbname): try: # open the wordpress config file with open(self.config_file_location, 'r') as wp_config: file_contents = wp_config.read() wp_config.close() # Comment out all uncommented db uncommentedDB = r'(...
IOError
dataset/ETHPy150Open huntlyc/Sublime-Wordpress-Dev-Plugin/wordpress_dev.py/WordpressDbSwitcherCommand.switch_active_database
3,449
def run(self): s = sublime.load_settings("WordPressDev.sublime-settings") config_file_location = s.get("wp_config_file") try: # open the wordpress config file with open(config_file_location, 'r') as wp_config: file_contents = wp_config.read() wp_c...
IOError
dataset/ETHPy150Open huntlyc/Sublime-Wordpress-Dev-Plugin/wordpress_dev.py/WordpressDebugToggleCommand.run
3,450
def get(self, path, default=None): """ Return the :class:`Page` object at ``path``, or ``default`` if there is no such page. """ # This may trigger the property. Do it outside of the try block. pages = self._pages try: return pages[path] except...
KeyError
dataset/ETHPy150Open SimonSapin/Flask-FlatPages/flask_flatpages/flatpages.py/FlatPages.get
3,451
def reload(self): """Forget all pages. All pages will be reloaded next time they're accessed. """ try: # This will "unshadow" the cached_property. # The property will be re-executed on next access. del self.__dict__['_pages'] except __HOLE__: ...
KeyError
dataset/ETHPy150Open SimonSapin/Flask-FlatPages/flask_flatpages/flatpages.py/FlatPages.reload
3,452
def _smart_html_renderer(self, html_renderer): """ Wrap the rendering function in order to allow the use of rendering functions with differing signatures. We stay backwards compatible by using reflection, i.e. we inspect the given rendering function's signature in order to find ...
TypeError
dataset/ETHPy150Open SimonSapin/Flask-FlatPages/flask_flatpages/flatpages.py/FlatPages._smart_html_renderer
3,453
@classmethod def is_valid_transition(cls, from_value, to_value): """ Will check if to_value is a valid transition from from_value. Returns true if it is a valid transition. :param from_value: Start transition point :param to_value: End transition point :type from_value: int :...
KeyError
dataset/ETHPy150Open 5monkeys/django-enumfield/django_enumfield/enum.py/Enum.is_valid_transition
3,454
def get_internal_wsgi_application(): """ Loads and returns the WSGI application as configured by the user in ``settings.WSGI_APPLICATION``. With the default ``startproject`` layout, this will be the ``application`` object in ``projectname/wsgi.py``. This function, and the ``WSGI_APPLICATION`` setti...
AttributeError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/core/servers/basehttp.py/get_internal_wsgi_application
3,455
def cpu_count_logical(): """Return the number of logical CPUs in the system.""" try: return os.sysconf("SC_NPROCESSORS_ONLN") except __HOLE__: # mimic os.cpu_count() behavior return None
ValueError
dataset/ETHPy150Open giampaolo/psutil/psutil/_pssunos.py/cpu_count_logical
3,456
@wrap_exceptions def exe(self): try: return os.readlink( "%s/%s/path/a.out" % (self._procfs_path, self.pid)) except __HOLE__: pass # continue and guess the exe name from the cmdline # Will be guessed later from cmdline but we want to explicitly ...
OSError
dataset/ETHPy150Open giampaolo/psutil/psutil/_pssunos.py/Process.exe
3,457
@wrap_exceptions def terminal(self): procfs_path = self._procfs_path hit_enoent = False tty = wrap_exceptions( cext.proc_basic_info(self.pid, self._procfs_path)[0]) if tty != cext.PRNODEV: for x in (0, 1, 2, 255): try: retur...
OSError
dataset/ETHPy150Open giampaolo/psutil/psutil/_pssunos.py/Process.terminal
3,458
@wrap_exceptions def cwd(self): # /proc/PID/path/cwd may not be resolved by readlink() even if # it exists (ls shows it). If that's the case and the process # is still alive return None (we can return None also on BSD). # Reference: http://goo.gl/55XgO procfs_path = self._pro...
OSError
dataset/ETHPy150Open giampaolo/psutil/psutil/_pssunos.py/Process.cwd
3,459
@wrap_exceptions def open_files(self): retlist = [] hit_enoent = False procfs_path = self._procfs_path pathdir = '%s/%d/path' % (procfs_path, self.pid) for fd in os.listdir('%s/%d/fd' % (procfs_path, self.pid)): path = os.path.join(pathdir, fd) if os.p...
OSError
dataset/ETHPy150Open giampaolo/psutil/psutil/_pssunos.py/Process.open_files
3,460
@wrap_exceptions def memory_maps(self): def toaddr(start, end): return '%s-%s' % (hex(start)[2:].strip('L'), hex(end)[2:].strip('L')) procfs_path = self._procfs_path retlist = [] rawlist = cext.proc_memory_maps(self.pid, procfs_path) ...
OSError
dataset/ETHPy150Open giampaolo/psutil/psutil/_pssunos.py/Process.memory_maps
3,461
def load_macros(self, version): vsbase = r"Software\Microsoft\VisualStudio\%0.1f" % version self.set_macro("VCInstallDir", vsbase + r"\Setup\VC", "productdir") self.set_macro("VSInstallDir", vsbase + r"\Setup\VS", "productdir") net = r"Software\Microsoft\.NETFramework" self.set_m...
KeyError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/distutils/msvccompiler.py/MacroExpander.load_macros
3,462
def initialize(self): self.__paths = [] if "DISTUTILS_USE_SDK" in os.environ and "MSSdk" in os.environ and self.find_exe("cl.exe"): # Assume that the SDK set up everything alright; don't try to be # smarter self.cc = "cl.exe" self.linker = "link.exe" ...
KeyError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/distutils/msvccompiler.py/MSVCCompiler.initialize
3,463
def compile(self, sources, output_dir=None, macros=None, include_dirs=None, debug=0, extra_preargs=None, extra_postargs=None, depends=None): if not self.initialized: self.initialize() macros, objects, extra_postargs, pp_opts, build = \ self._setup_compile...
KeyError
dataset/ETHPy150Open azoft-dev-team/imagrium/env/Lib/distutils/msvccompiler.py/MSVCCompiler.compile
3,464
def _adjust_child_weights(self, child_results, zones): """Apply the Scale and Offset values from the Zone definition to adjust the weights returned from the child zones. Alters child_results in place. """ for zone_id, result in child_results: if not result: ...
KeyError
dataset/ETHPy150Open nii-cloud/dodai-compute/nova/scheduler/abstract_scheduler.py/AbstractScheduler._adjust_child_weights
3,465
def xpath_tokenizer(pattern, namespaces=None): for token in xpath_tokenizer_re.findall(pattern): tag = token[1] if tag and tag[0] != "{" and ":" in tag: try: prefix, uri = tag.split(":", 1) if not namespaces: raise KeyError ...
KeyError
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/xml/etree/ElementPath.py/xpath_tokenizer
3,466
def prepare_predicate(next, token): # FIXME: replace with real parser!!! refs: # http://effbot.org/zone/simple-iterator-parser.htm # http://javascript.crockford.com/tdop/tdop.html signature = [] predicate = [] while 1: token = next() if token[0] == "]": break ...
IndexError
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/xml/etree/ElementPath.py/prepare_predicate
3,467
def iterfind(elem, path, namespaces=None): # compile selector pattern if path[-1:] == "/": path = path + "*" # implicit all (FIXME: keep this?) try: selector = _cache[path] except KeyError: if len(_cache) > 100: _cache.clear() if path[:1] == "/": r...
StopIteration
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/xml/etree/ElementPath.py/iterfind
3,468
def find(elem, path, namespaces=None): try: return next(iterfind(elem, path, namespaces)) except __HOLE__: return None ## # Find all matching objects.
StopIteration
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/xml/etree/ElementPath.py/find
3,469
def findtext(elem, path, default=None, namespaces=None): try: elem = next(iterfind(elem, path, namespaces)) return elem.text or "" except __HOLE__: return default
StopIteration
dataset/ETHPy150Open amrdraz/kodr/app/brython/www/src/Lib/xml/etree/ElementPath.py/findtext
3,470
def get_output(self, cmd): try: fnull = open(os.devnull, "w") process = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=fnull) fnull.close() except (__HOLE__, EnvironmentError): # can't use FileNotFoundError in Python 2 self.logger.debug("Subprocess ...
OSError
dataset/ETHPy150Open richrd/suplemon/suplemon/modules/linter.py/BaseLint.get_output
3,471
def is_accessible(self): try: return login.current_user.is_admin() except __HOLE__: pass return False
AttributeError
dataset/ETHPy150Open dchaplinsky/unshred-tag/admin/views.py/BaseAdminIndexView.is_accessible
3,472
def updateMessages(self, parameters): """Modifies the messages created by internal validation for each tool parameter. This method is called after internal validation.""" zone_parameter = parameters[0] input_parameter = parameters[1] variable_parameter = parameters[2] o...
RuntimeError
dataset/ETHPy150Open Esri/solutions-geoprocessing-toolbox/suitability/toolboxes/scripts/MultidimensionSupplementalTools/MultidimensionSupplementalTools/Scripts/mds/tools/multidimensional_zonal_statistics.py/MultidimensionalZonalStatistics.updateMessages
3,473
def execute(self, parameters, messages): """The source code of the tool.""" zone_parameter = parameters[0] input_parameter = parameters[1] variable_parameter = parameters[2] output_parameter = parameters[3] type_parameter = parameters[4] ignore_parameter = parame...
RuntimeError
dataset/ETHPy150Open Esri/solutions-geoprocessing-toolbox/suitability/toolboxes/scripts/MultidimensionSupplementalTools/MultidimensionSupplementalTools/Scripts/mds/tools/multidimensional_zonal_statistics.py/MultidimensionalZonalStatistics.execute
3,474
def get_object(self, queryset=None): """ Returns the object the view is displaying. By default this requires `self.queryset` and a `pk` or `slug` argument in the URLconf, but subclasses can override this to return any object. """ # Use a custom queryset if provided; this...
ObjectDoesNotExist
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/views/generic/detail.py/SingleObjectMixin.get_object
3,475
def read_char_no_blocking(): ''' Read a character in nonblocking mode, if no characters are present in the buffer, return an empty string ''' fd = sys.stdin.fileno() old_settings = termios.tcgetattr(fd) old_flags = fcntl.fcntl(fd, fcntl.F_GETFL) try: tty.setraw(fd, termios.TCSADRAIN) ...
IOError
dataset/ETHPy150Open pindexis/qfc/qfc/readchar.py/read_char_no_blocking
3,476
def command_schema(self, name=None): ''' Prints current database schema (according sqlalchemy database model):: ./manage.py sqla:schema [name] ''' meta_name = table_name = None if name: if isinstance(self.metadata, MetaData): table_name = ...
KeyError
dataset/ETHPy150Open SmartTeleMax/iktomi/iktomi/cli/sqla.py/Sqla.command_schema
3,477
def e(self): "Timezone name if available" try: if hasattr(self.data, 'tzinfo') and self.data.tzinfo: # Have to use tzinfo.tzname and not datetime.tzname # because datatime.tzname does not expect Unicode return self.data.tzinfo.tzname(self.data)...
NotImplementedError
dataset/ETHPy150Open AppScale/appscale/AppServer/lib/django-1.4/django/utils/dateformat.py/DateFormat.e
3,478
def get_diamond_version(): try: from diamond.version import __VERSION__ return __VERSION__ except __HOLE__: return "Unknown"
ImportError
dataset/ETHPy150Open BrightcoveOS/Diamond/src/diamond/util.py/get_diamond_version
3,479
@classmethod def convert_to_requested_unit_applier(cls, compatibles): def apply_requested_unit(target, _graph_config): tags = target['tags'] try: scale, extra_op = compatibles[tags['unit']] except (KeyError, __HOLE__): # this probably means...
ValueError
dataset/ETHPy150Open vimeo/graph-explorer/graph_explorer/query.py/Query.convert_to_requested_unit_applier
3,480
def pipedpath_constructor(loader, node): path = loader.construct_python_str(node) original_path = path package = piped # the path may be an empty string, which should be the root piped package path. if path: paths = path.split(os.path.sep) for i in range(1, len(paths)+1): ...
AttributeError
dataset/ETHPy150Open foundit/Piped/piped/yamlutil.py/pipedpath_constructor
3,481
def get_screenshot_as_file(self, filename): """ Gets the screenshot of the current window. Returns False if there is any IOError, else returns True. Use full paths in your filename. :Args: - filename: The full path you wish to save your screenshot to. :Usage: ...
IOError
dataset/ETHPy150Open apiad/sublime-browser-integration/selenium/webdriver/remote/webdriver.py/WebDriver.get_screenshot_as_file
3,482
def collect_posts(post_types, before_ts, per_page, tag, search=None, include_hidden=False): query = Post.query query = query.options( sqlalchemy.orm.subqueryload(Post.tags), sqlalchemy.orm.subqueryload(Post.mentions), sqlalchemy.orm.subqueryload(Post.reply_contexts), ...
ValueError
dataset/ETHPy150Open kylewm/redwind/redwind/views.py/collect_posts
3,483
def tearDown(self): super(TestAdministrativeFlows, self).tearDown() try: self.tempdir_overrider.Stop() except __HOLE__: pass
AttributeError
dataset/ETHPy150Open google/grr/grr/lib/flows/general/administrative_test.py/TestAdministrativeFlows.tearDown
3,484
def _make_text_safeish(text, fallback_encoding, method='decode'): # The unicode decode here is because sublime converts to unicode inside # insert in such a way that unknown characters will cause errors, which is # distinctly non-ideal... and there's no way to tell what's coming out of # git in output. ...
UnicodeDecodeError
dataset/ETHPy150Open kemayo/sublime-text-git/git/__init__.py/_make_text_safeish
3,485
def run(self): # Ignore directories that no longer exist if not os.path.isdir(self.working_dir): return self.command_lock.acquire() output = '' callback = self.on_done try: if self.working_dir != "": os.chdir(self.working_dir) ...
OSError
dataset/ETHPy150Open kemayo/sublime-text-git/git/__init__.py/CommandThread.run
3,486
def get_working_dir(self): file_name = self._active_file_name() if file_name: return os.path.realpath(os.path.dirname(file_name)) try: # handle case with no open folder return self.window.folders()[0] except __HOLE__: return ''
IndexError
dataset/ETHPy150Open kemayo/sublime-text-git/git/__init__.py/GitWindowCommand.get_working_dir
3,487
def _check_tile_metadata(path1, path2): """Given two tile paths, check that the projections, geotransforms and dimensions agree. Returns a message in string msg which, if empty, indicates agreement on the metadata.""" # pylint:disable=too-many-branches # pylint:disable=too-many-statements gdal....
RuntimeError
dataset/ETHPy150Open GeoscienceAustralia/agdc/src/tilecompare.py/_check_tile_metadata
3,488
def action_task_saved(sender, instance, created, **kwargs): if created: instance.project.create_action("created new task", author=instance.editor, action_object=instance) else: try: last_rev = instance.taskrevision_set\ .select_related('status')\ ...
IndexError
dataset/ETHPy150Open lukaszb/django-projector/projector/actions.py/action_task_saved
3,489
def get_etree(): ''' Returns an elementtree implementation. Searches for `lxml.etree`, then `xml.etree.cElementTree`, then `xml.etree.ElementTree`. ''' global _etree if _etree is None: try: from lxml import etree _etree = etree except ImportError: ...
ImportError
dataset/ETHPy150Open joelverhagen/flask-rauth/flask_rauth.py/get_etree
3,490
def __init__(self, filename): try: self.fp = open(filename, "rb") except __HOLE__ as err: Console.error("Could not open file: %s" % filename) raise err
IOError
dataset/ETHPy150Open zynga/jasy/jasy/asset/ImageInfo.py/ImgFile.__init__
3,491
def size(self): self.fp.seek(0) self.fp.read(2) b = self.fp.read(1) try: while (b and ord(b) != 0xDA): while (ord(b) != 0xFF): b = self.fp.read(1) while (ord(b) == 0xFF): b = self.fp.read(1) if (ord(b) >= 0xC0 and ord(b) <= 0x...
ValueError
dataset/ETHPy150Open zynga/jasy/jasy/asset/ImageInfo.py/JpegFile.size
3,492
def get_xy_rotation_and_scale(header): """ CREDIT: See IDL code at http://www.astro.washington.edu/docs/idl/cgi-bin/getpro/library32.html?GETROT """ def calc_from_cd(cd1_1, cd1_2, cd2_1, cd2_2): # TODO: Check if first coordinate in CTYPE is latitude # if (ctype EQ 'DEC-') or (strmi...
KeyError
dataset/ETHPy150Open ejeschke/ginga/ginga/util/wcs.py/get_xy_rotation_and_scale
3,493
@patch("sys.stdout") def test_clt_fetch_dlo(self, mock_stdout): clt = self.client mgr = clt._manager cont = self.container ctype = "text/fake" num_objs = random.randint(1, 3) objs = [StorageObject(cont.object_manager, {"name": "obj%s" % num, "content_t...
StopIteration
dataset/ETHPy150Open rackspace/pyrax/tests/unit/test_object_storage.py/ObjectStorageTest.test_clt_fetch_dlo
3,494
@verbose def read_ica(fname): """Restore ICA solution from fif file. Parameters ---------- fname : str Absolute path to fif file containing ICA matrices. The file name should end with -ica.fif or -ica.fif.gz. Returns ------- ica : instance of ICA The ICA estimator. ...
ValueError
dataset/ETHPy150Open mne-tools/mne-python/mne/preprocessing/ica.py/read_ica
3,495
def create(config_id, raw_configs, set_defaults=False): sections = {} all_values = defaultdict(set) def init_section(section_name, section_dto=None): try: return sections[section_name] except __HOLE__: section_dto = section_dto or {} section_dto['dbo_id']...
KeyError
dataset/ETHPy150Open genzgd/Lampost-Mud/lampost/gameops/dbconfig.py/create
3,496
def real_root(arg, n=None): """Return the real nth-root of arg if possible. If n is omitted then all instances of (-n)**(1/odd) will be changed to -n**(1/odd); this will only create a real root of a principle root -- the presence of other factors may cause the result to not be real. Examples ==...
ValueError
dataset/ETHPy150Open sympy/sympy/sympy/functions/elementary/miscellaneous.py/real_root
3,497
@register.tag def get_photo(parser, token): """Get a single photo from the photologue library and return the img tag to display it. Takes 3 args: - the photo to display. This can be either the slug of a photo, or a variable that holds either a photo instance or a integer (photo id) - the photosiz...
ValueError
dataset/ETHPy150Open jdriscoll/django-photologue/photologue/templatetags/photologue_tags.py/get_photo
3,498
@register.tag def get_rotating_photo(parser, token): """Pick at random a photo from a given photologue gallery and return the img tag to display it. Takes 3 args: - the gallery to pick a photo from. This can be either the slug of a gallery, or a variable that holds either a gallery instance or a gall...
ValueError
dataset/ETHPy150Open jdriscoll/django-photologue/photologue/templatetags/photologue_tags.py/get_rotating_photo
3,499
def iter_first(sequence): """Get the first element from an iterable or raise a ValueError if the iterator generates no values. """ it = iter(sequence) try: if PY3: return next(it) else: return it.next() except __HOLE__: raise ValueError() # Excep...
StopIteration
dataset/ETHPy150Open beetbox/beets/beets/util/confit.py/iter_first