function
stringlengths
11
56k
repo_name
stringlengths
5
60
features
list
def test_get_user_positions(self): """ Get user positions """ user1 = UserFactory(weekly_result=100) user2 = UserFactory(weekly_result=300, monthly_result=300, reputation=Decimal(300)) user3 = AdminFactory() user4 = UserFactory(monthly_result=100, reputation=Decim...
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_save_profile(self): """ Save profile """ user = UserFactory() # save_profile(user,
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_topup_accounts_task(self): """ Topup """ user = UserFactory() topup_accounts_task() user.refresh_from_db() self.assertEqual(config.DAILY_TOPUP, user.total_cash) # TODO mock and test exception
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_topup_accounts_task_error(self, logger, topup_cash): UserFactory() topup_cash.side_effect = Exception() topup_accounts_task() logger.exception.assert_called_once()
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_create_accounts_snapshot(self): user = UserFactory() create_accounts_snapshot() # TODO mock logger and create_snapshot()
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_user_home(self): """ User home """ user = UserFactory() user_templatetag = user_home(user, 1000, True) self.assertEqual({ 'user': user, 'reputation_change': 1000, 'is_formatted': True }, user_templatetag) user_t...
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_get_reputation_history(self): """ Get reputation history """ # TODO
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_last_week_reputation_change(self): """ Get last week reputation change """ # TODO
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_startswith(self): """ Startswith """ start_path = reverse('accounts:rank') path = reverse('accounts:rank') self.assertTrue(startswith(path, start_path))
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def test_process_username(self): """ Process username """ username = process_username(u"zażółćgęśląjaźń") self.assertEqual('zazolcgeslajazn', username) UserFactory(username='zazolcgeslajazn') username2 = process_username(u"zażółćgęśląjaźń") self.assertNotE...
KlubJagiellonski/Politikon
[ 20, 21, 20, 29, 1433923333 ]
def kwargs_required(*required_args): def decorate(func): @wraps(func) def wrapper(*args, **kwargs): for arg in required_args: if arg not in kwargs: return abort(400, "Argument <{0}> is required".format(arg)) return func(*args, **kwargs) ...
pycook/cmdb
[ 473, 186, 473, 44, 1451356369 ]
def decorate(func): @wraps(func) def wrapper(*args, **kwargs): for arg in required_args: if arg not in request.values: return abort(400, "Argument <{0}> is required".format(arg)) return func(*args, **kwargs) return wrapper
pycook/cmdb
[ 473, 186, 473, 44, 1451356369 ]
def __init__( self, xml, cwd, default): xbmcgui.WindowXMLDialog.__init__(self)
Xycl/plugin.image.mypicsdb
[ 12, 20, 12, 2, 1344354926 ]
def onAction( self, action ): # Close if ( action.getId() in CANCEL_DIALOG or self.getFocusId() == BUTTON_CLOSE and action.getId() in SELECT_ITEM ): self.close() # Zoom in elif ( action.getId() in SELECT_ITEM and self.getFocusId() == BUTTON_ZOOM_IN or action in ACTION_UP): ...
Xycl/plugin.image.mypicsdb
[ 12, 20, 12, 2, 1344354926 ]
def set_place(self, place): self.place = place
Xycl/plugin.image.mypicsdb
[ 12, 20, 12, 2, 1344354926 ]
def set_pic(self, pic): pass
Xycl/plugin.image.mypicsdb
[ 12, 20, 12, 2, 1344354926 ]
def set_map(self, mapfile): self.getControl( GOOGLE_MAP ).setImage(mapfile)
Xycl/plugin.image.mypicsdb
[ 12, 20, 12, 2, 1344354926 ]
def setup_all( self, filtersettings = ""): self.getControl( LABEL_TEXT ).setLabel( common.getstring(30220) )
Xycl/plugin.image.mypicsdb
[ 12, 20, 12, 2, 1344354926 ]
def zoom(self,way,step=1): if way=="+": self.zoomlevel = self.zoomlevel + step elif way=="-": self.zoomlevel = self.zoomlevel - step else: self.zoomlevel = step if self.zoomlevel > self.zoom_max: self.zoomlevel = self.zoom_max elif self.zoomlev...
Xycl/plugin.image.mypicsdb
[ 12, 20, 12, 2, 1344354926 ]
def test_1(self, completion): assert completion
scop/bash-completion
[ 2349, 352, 2349, 219, 1455029043 ]
def test_2(self, completion): assert completion
scop/bash-completion
[ 2349, 352, 2349, 219, 1455029043 ]
def test_all_message_ids(self, completion): assert any("-" in x for x in completion)
scop/bash-completion
[ 2349, 352, 2349, 219, 1455029043 ]
def test_enabled_message_ids(self, completion): assert any("-" in x for x in completion)
scop/bash-completion
[ 2349, 352, 2349, 219, 1455029043 ]
def init(mode=None, **kwargs): """Wrapper to create the API object you need to acces the CCU API. By default it detects whether or not this code is being executed on the CCU or on another system. And initializes either a LocalAPI() object when run directly on a CCU or, in all other cases, a RemoteAPI()...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _replace_wrong_encoded_json(self, text): return text.replace("\\{", "{")\ .replace("\\[", "[")\ .replace("\\/", "/")
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _register_atexit_handler(self): """Can be called to register a cleanup handler on interpreter exit. The APIs can register this to ensures the close() method is called on interpreter shutdown.""" atexit.register(self.close)
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _parse_api_response(self, method_name_int, kwargs, body): # FIXME: The ccu is performing wrong encoding at least for output of # executed rega scripts. But maybe this is a generic problem. Let's see # and only fix the known issues for the moment. if method_name_int in [ "rega_run_scr...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def __del__(self): """When object is removed, the close() method is called.""" if self._constructed: self.close()
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def __getattr__(self, method_name_int): """Realizes dynamic methods based on the methods supported by the API. The method names are nearly the same as provided by the CCU (see http://[CCU_ADDRESS]/api/homematic.cgi or API.print_methods()). The method names are slighly renamed. For examp...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _initialize(self): if self.initialized: return self._fail_exc = None self.logger.debug("[API] Initializing...") try: self._initialize_api() self._initialized = True self.logger.debug("[API] Initialized") except Exception as e: ...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _get_methods_config(self): """Gathers the method configuration file from the CCU. Returns the method configuration as list of lines. Each of these lines is a unicode string. Has to be implemented by the specific API class.""" raise NotImplementedError()
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def initialized(self): """Tells the caller whether or not the "connection" with the CCU is ready for other API calls.""" with self._api_lock: return self._initialized
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def fail_reason(self): """When the API has not been initialized successfully, this provides access to the exception caused the problem. Otherwise it is set to *None*.""" return self._fail_exc
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _call(self, method_name_int, **kwargs): # pylint:disable=unused-argument """Realizes the API calls. Has to be implemented by the specific API class.""" raise NotImplementedError()
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def print_methods(self): """Prints a description of the available API methods. This information has been fetched from the CCU before. This might be useful for working with the API to gather infos about the available calls. """ with self._api_lock: self._initialize() ...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _init_methods(self): """Parses the method configuration read from the CCU. The method configuration read with _get_methods_config() is being parsed here to initialize the self._methods dictionary which holds all need information about the available API methods. """ s...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def __init__(self, address, credentials, connect_timeout=10, http_auth=None): self._session_id = None self._address = None self._credentials = None self._http_auth = None self._connect_timeout = None super(RemoteAPI, self).__init__() self....
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _set_credentials(self, credentials): if not isinstance(credentials, tuple): raise PMException("Please specify the user credentials to log in to the CCU " "like this: \"(username, password)\".") elif len(credentials) != 2: raise PMException("The c...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _set_connect_timeout(self, timeout): if type(timeout) not in [ int, float ]: raise PMException("Invalid timeout value. Must be of type int or float.") self._connect_timeout = timeout
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def address(self): return self._address
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def close(self): with self._api_lock: self._logout()
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _initialize_api(self): self._login() self._init_methods() self._register_atexit_handler()
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _get_methods_config(self): # Can not use API.rega_run_script() here since the method infos are not yet # available. User code should use API.rega_run_script(). response = self._call("rega_run_script", _session_id_=self._session_id, script="string stderr;\n" ...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _login(self): if self._session_id is not None: raise PMException("Already logged in.") response = self._call("session_login", username=self._credentials[0], password=self._credentials[1]) if response is None: raise PMExce...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _logout(self): if self._session_id is not None: self._call("session_logout", _session_id_=self._session_id) self._session_id = None
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _call(self, method_name_int, **kwargs): """Runs the provided method, which needs to be one of the methods which are available on the device (with the given arguments) on the CCU.""" with self._api_lock: return self._do_call(method_name_int, **kwargs)
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _do_call(self, method_name_int, **kwargs): method = self._get_method(method_name_int) args = self._get_arguments(method, kwargs) self.logger.debug("CALL: %s ARGS: %r", method["NAME"], args) #import traceback #stack = "" #("".join(traceback.format_stack()[:-1])).encode("utf...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _get_method(self, method_name_int): """This wrapper allows specific API calls which are needed before the real list of methods is available, so allow it to be not validated and fake the method response.""" try: return super(RemoteAPI, self)._get_method(method_name_int) ex...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _get_arguments(self, method, args): if "_session_id_" in method["ARGUMENTS"] and self._session_id: args["_session_id_"] = self._session_id return args
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def __init__(self): super(LocalAPI, self).__init__() self._tclsh = None self._constructed = True
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _initialize_api(self): self._init_tclsh() self._init_methods() self._register_atexit_handler()
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _init_tclsh(self): try: self._tclsh = subprocess.Popen(["/bin/tclsh"], stdin=subprocess.PIPE, stdout=subprocess.PIPE, #stderr=subprocess.PIPE, cwd="/www/api", shell=False) except OSError as e: if e.errno == 2: ...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _get_methods_config(self): return open(self._methods_file).read().decode("latin-1").split("\r\n")
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _call(self, method_name_int, **kwargs): """Runs the given API method directly on the CCU using a tclsh process. The API method needs to be one of the methods which are available on the device (with the given arguments).""" with self._api_lock: try: return...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _do_call(self, method_name_int, **kwargs): method = self._get_method(method_name_int) parsed_args = self._get_args(method, kwargs) file_path = "/www/api/methods/%s" % method["SCRIPT_FILE"] self.logger.debug("CALL: %s ARGS: %r", method["SCRIPT_FILE"], parsed_args) tcl = "" ...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _get_args(self, method, args): def quote_string(s): return "\"%s\"" % s.replace("\"", "\\\"") args_parsed = "[list " for arg_name in method["ARGUMENTS"]: try: if arg_name == "_session_id_" and arg_name not in args: val = quote_stri...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def close(self): """Closes the "connection" with the CCU. In fact it terminates the tclsh process.""" with self._api_lock: if self._tclsh: self._tclsh.kill() self._tclsh = None
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def __init__(self, api, max_cache_age=360): dict.__init__(self) self._api = api self._max_cache_age = max_cache_age # seconds self._last_update = None self._lock = threading.Lock()
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def __getitem__(self, key): self._update_data() return dict.__getitem__(self, key)
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def values(self): self._update_data() return dict.values(self)
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def __setitem__(self, key, val): raise PMException("Can not be changed.")
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _update(self): # Incoming dict keys are camel cased. uah. # The dict keys are directly handed over to the device/channel objects. So they # need ot be equalized and with internal naming specs just like the also different # keys from the XML-RPC messages. def decamel_dict_keys...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def _update(self): # Incoming dict keys are camel cased. uah. # The dict keys are directly handed over to the device/channel objects. So they # need ot be equalized and with internal naming specs just like the also different # keys from the XML-RPC messages. def decamel_dict_keys...
LaMi-/pmatic
[ 33, 23, 33, 14, 1451661313 ]
def update_print(apibase, password, print_id, progress): """ """ params = {'id': print_id} data = dict(progress=progress, password=password)
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def finish_print(apibase, password, print_id, print_info): """ """ params = {'id': print_id} print_info.update(dict(password=password))
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def update_scan(apibase, password, scan_id, progress): """ """ params = {'id': scan_id}
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def finish_scan(apibase, password, scan_id, uploaded_file, print_id, print_page_number, print_href, min_coord, max_coord, geojpeg_bounds): """ """ params = {'id': scan_id} data = { 'print_id': print_id, 'print_page_number': print_page_number, 'print_href': print_href,...
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def fail_scan(apibase, password, scan_id): """ """ params = {'id': scan_id} data = {'password': password}
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def finish_form(apibase, password, form_id, action_url, http_method, title, fields): """ """ data = dict(password=password, action_url=action_url, http_method=http_method, title=title)
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def fail_form(apibase, password, form_id): """ """ params = {'id': form_id} data = {'password': password}
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def upload(params, file_path, file_contents, apibase, password): """ Upload a file via the API append.php form input provision thingie. This allows uploads to either target S3 or the app itself. """ params.update(dict(password=password, dirname=dirname(file_path), ...
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def append_print_file(print_id, file_path, file_contents, apibase, password): """ Upload a print. """ params = { "print": print_id, } return upload(params, file_path, file_contents, apibase, password)
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def get_print_info(print_url): """ """ print print_url res = requests.get(print_url, headers=dict(Accept='application/paperwalking+xml')) if res.status_code == 404: raise Exception("No such atlas: %s" % print_url) print_ = ElementTree.parse(StringIO(res.text)).getroot()
stamen/fieldpapers
[ 100, 10, 100, 3, 1320352055 ]
def __init__(self, db): """ NOTE: This class does not commit any changes to the db. That must be done from the calling environment. @type db: Cerebrum.database.Database @param db: A database connection. """ self.db = db self.co = Factory.get('Constants')(db) ...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def group_create(self, group_name, description, creator, owner, url=None, forward=None): """ This method creates a new VirtHome group. NOTE: Some group name formats are reserved for specific applications! This method WILL allow creation of reserved group names. @type group_name: str ...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def group_disable(self, group): """This method removes all members and auth data related to a group, effectively disabling it without actually 'nuking' it. @type group_name: str @param group_name: The name of the group that should be joined @rtype: str @return: The name...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def __init__(self, db): self.db = db self.co = Factory.get('Constants')(db) self.clconst = Factory.get('CLConstants')(db) self.group_class = Factory.get('Group') self.account_class = Factory.get('Account') # Or compile on each call to self.url_whitelist = [re.co...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def list_group_members(self, group, indirect_members=False): """ This methid lists members of a group. It does NOT include operators or moderators, unless they are also members. @type group: Cerebrum.Group @param group: The group to list members of @type indirect: bool ...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def get_trait_val(self, entity, trait_const, val='strval'): """Get the trait value of type L{val} of L{entity} that is of type L{trait_const}. @type entity: Cerebrum.Entity @param entity: The entity which trait is being looked up @type trait_const: _EntityTraitCode @par...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def setup_event_request(self, issuer_id, event_type, params=None, change_by=None ): """ Perform the necessary magic when creating a pending confirmation event (i.e. create a changelog entry with the event). @type issuer_id: int @param issuer_id: The C{entity_id} of the event creator/inv...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def account_exists(self, account_name): """Check that L{account_name} is available in Cerebrum/Virthome. Names are case sensitive, but there should not exist two accounts with same name in lowercase, due to LDAP, so we have to check this too. (The combination if this call and account.wr...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def create_account(self, account_type, account_name, email, expire_date, human_first_name, human_last_name, with_confirmation=True): """Create an account of the specified type. This is a convenience function to avoid duplicating some of the work. @type account_type: subclass of Bas...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def find_or_create_op_target(self, entity_id, target_type): """ Finds an op-target of type L{target_type} that points to L{entity_id}. If no targets exist, one will be created. """ aot = BofhdAuthOpTarget(self.db) op_targets = [t for t in aot.list(entity_id=entity_id, ...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def remove_auth_roles(self, entity_id): """ This method will remove all authorization roles that has been given to an entity. It will also remove any remaining authorization targets that no longer have auth roles pointing to it as a result. @type entity_id: int @param entity_id:...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def list_group_moderators(self, group): """ List moderators of C{group}. @type group: Cerebrum.Group @param group: A populated group object to list 'admins' for. @rtype: list @return: A list of dictionaries with keys: ['account_id', 'account_name', 'owner_name'...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def list_groups_moderated(self, account): """ List groups moderated by C{account} @type account: Cerebrum.Account @param account: A populated account object to list 'groups' for. @rtype: list @return: A list of dictionaries with keys: ['group_id', 'group_name',...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def in_realm(self, name, realm, strict=True): """ Simple test - is the given L{name} in the realm L{realm} @type name: str @param name: The name (account name group name) @type realm: str @param realm: The realm, e.g. 'webid.uio.no' @type strict: bool @param st...
unioslo/cerebrum
[ 9, 3, 9, 40, 1396362121 ]
def __init__(self): self._setupped = False
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def _process_7z_names(self, fd): START = "----------" names = [] started = False item = {} while True: try: line = fd.readline() except: break if line: line = line.rstrip(os.linesep) ...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def set_files(self, files, extracted=False): """Set the files that the extractor should extract from the archive in the order of extraction. Normally one would get the list of all files in the archive using get_files(), then filter and/or permute this list before sending it back using se...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def get_mime_type(self): """Return the mime type name of the extractor's current archive.""" return self._type
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def extract(self): """Start extracting the files in the file list one by one using a new thread. Every time a new file is extracted a notify() will be signalled on the Condition that was returned by setup(). """ self._extract_thread = threading.Thread(target=self._thread_extract)...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def _thread_extract(self): """Extract the files in the file list one by one.""" # Extract 7z and rar whole archive - if it SOLID - extract one file is SLOW if self._type in (SEVENZIP,) and _7z_exec is not None: cmd = [_7z_exec, 'x', '-bd', '-p-', '-o' + self._dst, ...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def extract_file_io(self, chosen): """Extract the file named <name> to the destination directory, mark the file as "ready", then signal a notify() on the Condition returned by setup(). """ if os.path.exists(os.path.join(self._dst, chosen)): cStringIO.StringIO(open(os...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def __init__(self, image_files, other_files, archive_path, base_name): """Setup a Packer object to create a ZIP archive at <archive_path>. All files pointed to by paths in the sequences <image_files> and <other_files> will be included in the archive when packed. The files in <image_file...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def wait(self): """Block until the packer thread has finished. Return True if the packer finished its work successfully. """ if self._pack_thread is not None: self._pack_thread.join() return self._packing_successful
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def archive_mime_type(path): """Return the archive type of <path> or None for non-archives.""" try: if os.path.isfile(path): if not os.access(path, os.R_OK): return None if zipfile.is_zipfile(path): return ZIP fd = open(path, 'rb') ...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def get_archive_info(path): """Return a tuple (mime, num_pages, size) with info about the archive at <path>, or None if <path> doesn't point to a supported archive. """ image_re = re.compile('\.(' + '|'.join(get_supported_format_extensions_preg()) + ')\s*$', re.I) extractor = Extractor() extract...
Joacchim/Comix
[ 18, 14, 18, 1, 1286194888 ]
def setup_page_type(cls, gdbtype: gdb.Type) -> None: # TODO: should check config, but that failed to work on ppc64, hardcode # 64k for now if crash.current_target().arch.name() == "powerpc:common64": cls.PAGE_SHIFT = 16 # also a config cls.directmap_base = 0xc...
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]
def setup_mem_section(cls, gdbtype: gdb.Type) -> None: # TODO assumes SPARSEMEM_EXTREME cls.SECTIONS_PER_ROOT = cls.PAGE_SIZE // gdbtype.sizeof
jeffmahoney/crash-python
[ 61, 23, 61, 13, 1455127548 ]