idx int64 0 63k | question stringlengths 53 5.28k | target stringlengths 5 805 |
|---|---|---|
35,400 | def _parse_action_list_attribute ( attribute ) : actions = [ ] for action_call in attribute . split ( ';' ) : action_call = action_call . strip ( ) if action_call : actions . append ( _parse_action ( action_call ) ) return actions | Parses a list of actions as found in the effect attribute of transitions and the enry and exit actions of states . |
35,401 | def print_status ( self ) : s = [ ] s . append ( '=== State Machines: ===\n' ) for stm_id in Driver . _stms_by_id : stm = Driver . _stms_by_id [ stm_id ] s . append ( ' - {} in state {}\n' . format ( stm . id , stm . state ) ) s . append ( '=== Events in Queue: ===\n' ) for event in self . _event_queue . queue : if ... | Provide a snapshot of the current status . |
35,402 | def add_machine ( self , machine ) : self . _logger . debug ( 'Adding machine {} to driver' . format ( machine . id ) ) machine . _driver = self machine . _reset ( ) if machine . id is not None : Driver . _stms_by_id [ machine . id ] = machine self . _add_event ( event_id = None , args = [ ] , kwargs = { } , stm = mach... | Add the state machine to this driver . |
35,403 | def start ( self , max_transitions = None , keep_active = False ) : self . _active = True self . _max_transitions = max_transitions self . _keep_active = keep_active self . thread = Thread ( target = self . _start_loop ) self . thread . start ( ) | Start the driver . |
35,404 | def wait_until_finished ( self ) : try : self . thread . join ( ) except KeyboardInterrupt : self . _logger . debug ( 'Keyboard interrupt detected, stopping driver.' ) self . _active = False self . _wake_queue ( ) | Blocking method to wait until the driver finished its execution . |
35,405 | def _check_timers ( self ) : if self . _timer_queue : timer = self . _timer_queue [ 0 ] if timer [ 'timeout_abs' ] < _current_time_millis ( ) : self . _timer_queue . pop ( 0 ) self . _logger . debug ( 'Timer {} expired for stm {}, adding it to event queue.' . format ( timer [ 'id' ] , timer [ 'stm' ] . id ) ) self . _a... | Check for expired timers . |
35,406 | def send ( self , message_id , stm_id , args = [ ] , kwargs = { } ) : if stm_id not in Driver . _stms_by_id : self . _logger . warn ( 'Machine with name {} cannot be found. ' 'Ignoring message {}.' . format ( stm_id , message_id ) ) else : stm = Driver . _stms_by_id [ stm_id ] self . _add_event ( message_id , args , kw... | Send a message to a state machine handled by this driver . |
35,407 | def get_group ( self , name , user_name = None ) : return self . service . get_group ( name , user_name , self . url_prefix , self . auth , self . session , self . session_send_opts ) | Get owner of group and the resources it s attached to . |
35,408 | def add_permissions ( self , grp_name , resource , permissions ) : self . service . add_permissions ( grp_name , resource , permissions , self . url_prefix , self . auth , self . session , self . session_send_opts ) | Add additional permissions for the group associated with the given resource . |
35,409 | def create ( self , resource ) : return self . service . create ( resource , self . url_prefix , self . auth , self . session , self . session_send_opts ) | Create the given resource . |
35,410 | def _init_project_service ( self , version ) : project_cfg = self . _load_config_section ( CONFIG_PROJECT_SECTION ) self . _token_project = project_cfg [ CONFIG_TOKEN ] proto = project_cfg [ CONFIG_PROTOCOL ] host = project_cfg [ CONFIG_HOST ] self . _project = ProjectService ( host , version ) self . _project . base_p... | Method to initialize the Project Service from the config data |
35,411 | def _init_metadata_service ( self , version ) : metadata_cfg = self . _load_config_section ( CONFIG_METADATA_SECTION ) self . _token_metadata = metadata_cfg [ CONFIG_TOKEN ] proto = metadata_cfg [ CONFIG_PROTOCOL ] host = metadata_cfg [ CONFIG_HOST ] self . _metadata = MetadataService ( host , version ) self . _metadat... | Method to initialize the Metadata Service from the config data |
35,412 | def _init_volume_service ( self , version ) : volume_cfg = self . _load_config_section ( CONFIG_VOLUME_SECTION ) self . _token_volume = volume_cfg [ CONFIG_TOKEN ] proto = volume_cfg [ CONFIG_PROTOCOL ] host = volume_cfg [ CONFIG_HOST ] self . _volume = VolumeService ( host , version ) self . _volume . base_protocol = ... | Method to initialize the Volume Service from the config data |
35,413 | def _load_config_section ( self , section_name ) : if self . _config . has_section ( section_name ) : section = dict ( self . _config . items ( section_name ) ) elif self . _config . has_section ( "Default" ) : section = dict ( self . _config . items ( "Default" ) ) else : raise KeyError ( ( "'{}' was not found in the ... | Method to load the specific Service section from the config file if it exists or fall back to the default |
35,414 | def get_group ( self , name , user_name = None ) : self . project_service . set_auth ( self . _token_project ) return self . project_service . get_group ( name , user_name ) | Get information on the given group or whether or not a user is a member of the group . |
35,415 | def list_group_members ( self , name ) : self . project_service . set_auth ( self . _token_project ) return self . project_service . list_group_members ( name ) | Get the members of a group . |
35,416 | def get_permissions ( self , grp_name , resource ) : self . project_service . set_auth ( self . _token_project ) return self . project_service . get_permissions ( grp_name , resource ) | Get permissions associated the group has with the given resource . |
35,417 | def add_permissions ( self , grp_name , resource , permissions ) : self . project_service . set_auth ( self . _token_project ) self . project_service . add_permissions ( grp_name , resource , permissions ) | Add additional permissions for the group associated with the resource . |
35,418 | def update_permissions ( self , grp_name , resource , permissions ) : self . project_service . set_auth ( self . _token_project ) self . project_service . update_permissions ( grp_name , resource , permissions ) | Update permissions for the group associated with the given resource . |
35,419 | def delete_user_role ( self , user , role ) : self . project_service . set_auth ( self . _token_project ) self . project_service . delete_user_role ( user , role ) | Remove role from given user . |
35,420 | def get_user_groups ( self , user ) : self . project_service . set_auth ( self . _token_project ) return self . project_service . get_user_groups ( user ) | Get user s group memberships . |
35,421 | def _list_resource ( self , resource ) : self . project_service . set_auth ( self . _token_project ) return super ( BossRemote , self ) . list_project ( resource = resource ) | List all instances of the given resource type . |
35,422 | def list_experiments ( self , collection_name ) : exp = ExperimentResource ( name = '' , collection_name = collection_name , coord_frame = 'foo' ) return self . _list_resource ( exp ) | List all experiments that belong to a collection . |
35,423 | def list_channels ( self , collection_name , experiment_name ) : dont_care = 'image' chan = ChannelResource ( name = '' , collection_name = collection_name , experiment_name = experiment_name , type = dont_care ) return self . _list_resource ( chan ) | List all channels belonging to the named experiment that is part of the named collection . |
35,424 | def create_project ( self , resource ) : self . project_service . set_auth ( self . _token_project ) return self . project_service . create ( resource ) | Create the entity described by the given resource . |
35,425 | def list_metadata ( self , resource ) : self . metadata_service . set_auth ( self . _token_metadata ) return self . metadata_service . list ( resource ) | List all keys associated with the given resource . |
35,426 | def create_metadata ( self , resource , keys_vals ) : self . metadata_service . set_auth ( self . _token_metadata ) self . metadata_service . create ( resource , keys_vals ) | Associates new key - value pairs with the given resource . |
35,427 | def get_metadata ( self , resource , keys ) : self . metadata_service . set_auth ( self . _token_metadata ) return self . metadata_service . get ( resource , keys ) | Gets the values for given keys associated with the given resource . |
35,428 | def update_metadata ( self , resource , keys_vals ) : self . metadata_service . set_auth ( self . _token_metadata ) self . metadata_service . update ( resource , keys_vals ) | Updates key - value pairs with the given resource . |
35,429 | def delete_metadata ( self , resource , keys ) : self . metadata_service . set_auth ( self . _token_metadata ) self . metadata_service . delete ( resource , keys ) | Deletes the given key - value pairs associated with the given resource . |
35,430 | def parse_bossURI ( self , uri ) : t = uri . split ( "://" ) [ 1 ] . split ( "/" ) if len ( t ) is 3 : return self . get_channel ( t [ 2 ] , t [ 0 ] , t [ 1 ] ) raise ValueError ( "Cannot parse URI " + uri + "." ) | Parse a bossDB URI and handle malform errors . |
35,431 | def views ( model : "Model" ) -> list : if not isinstance ( model , Model ) : raise TypeError ( "Expected a Model, not %r." % model ) return model . _model_views [ : ] | Return a model s views keyed on what events they respond to . |
35,432 | def view ( model : "Model" , * functions : Callable ) -> Optional [ Callable ] : if not isinstance ( model , Model ) : raise TypeError ( "Expected a Model, not %r." % model ) def setup ( function : Callable ) : model . _model_views . append ( function ) return function if functions : for f in functions : setup ( f ) el... | A decorator for registering a callback to a model |
35,433 | def before ( self , callback : Union [ Callable , str ] ) -> "Control" : if isinstance ( callback , Control ) : callback = callback . _before self . _before = callback return self | Register a control method that reacts before the trigger method is called . |
35,434 | def after ( self , callback : Union [ Callable , str ] ) -> "Control" : if isinstance ( callback , Control ) : callback = callback . _after self . _after = callback return self | Register a control method that reacts after the trigger method is called . |
35,435 | def serve_static ( app , base_url , base_path , index = False ) : @ app . route ( base_url + '/(.*)' ) def serve ( env , req ) : try : base = pathlib . Path ( base_path ) . resolve ( ) path = ( base / req . match . group ( 1 ) ) . resolve ( ) except FileNotFoundError : return Response ( None , 404 , 'Not Found' ) if ba... | Serve a directory statically |
35,436 | def serve_doc ( app , url ) : @ app . route ( url , doc = False ) def index ( env , req ) : ret = '' for d in env [ 'doc' ] : ret += 'URL: {url}, supported methods: {methods}{doc}\n' . format ( ** d ) return ret | Serve API documentation extracted from request handler docstrings |
35,437 | def parse_args ( args = sys . argv [ 1 : ] ) : parser = argparse . ArgumentParser ( ) parser . add_argument ( '-a' , '--address' , help = 'address to listen on, default localhost' , default = 'localhost' ) parser . add_argument ( '-p' , '--port' , help = 'port to listen on, default 1234' , default = 1234 , type = int )... | Parse command line arguments for Grole server running as static file server |
35,438 | def main ( args = sys . argv [ 1 : ] ) : args = parse_args ( args ) if args . verbose : logging . basicConfig ( level = logging . DEBUG ) elif args . quiet : logging . basicConfig ( level = logging . ERROR ) else : logging . basicConfig ( level = logging . INFO ) app = Grole ( ) serve_static ( app , '' , args . directo... | Run Grole static file server |
35,439 | async def _read ( self , reader ) : start_line = await self . _readline ( reader ) self . method , self . location , self . version = start_line . decode ( ) . split ( ) path_query = urllib . parse . unquote ( self . location ) . split ( '?' , 1 ) self . path = path_query [ 0 ] self . query = { } if len ( path_query ) ... | Parses HTTP request into member variables |
35,440 | async def _buffer_body ( self , reader ) : remaining = int ( self . headers . get ( 'Content-Length' , 0 ) ) if remaining > 0 : try : self . data = await reader . readexactly ( remaining ) except asyncio . IncompleteReadError : raise EOFError ( ) | Buffers the body of the request |
35,441 | def route ( self , path_regex , methods = [ 'GET' ] , doc = True ) : def register_func ( func ) : if doc : self . env [ 'doc' ] . append ( { 'url' : path_regex , 'methods' : ', ' . join ( methods ) , 'doc' : func . __doc__ } ) for method in methods : self . _handlers [ method ] . append ( ( re . compile ( path_regex ) ... | Decorator to register a handler |
35,442 | async def _handle ( self , reader , writer ) : peer = writer . get_extra_info ( 'peername' ) self . _logger . debug ( 'New connection from {}' . format ( peer ) ) try : while True : req = Request ( ) await req . _read ( reader ) res = None for path_regex , handler in self . _handlers . get ( req . method , [ ] ) : matc... | Handle a single TCP connection |
35,443 | def run ( self , host = 'localhost' , port = 1234 ) : loop = asyncio . get_event_loop ( ) coro = asyncio . start_server ( self . _handle , host , port , loop = loop ) try : server = loop . run_until_complete ( coro ) except Exception as e : self . _logger . error ( 'Could not launch server: {}' . format ( e ) ) return ... | Launch the server . Will run forever accepting connections until interrupted . |
35,444 | def hold ( model : Model , reducer : Optional [ Callable ] = None ) -> Iterator [ list ] : if not isinstance ( model , Model ) : raise TypeError ( "Expected a Model, not %r." % model ) events = [ ] restore = model . __dict__ . get ( "_notify_model_views" ) model . _notify_model_views = lambda e : events . extend ( e ) ... | Temporarilly withold change events in a modifiable list . |
35,445 | def rollback ( model : Model , undo : Optional [ Callable ] = None , * args , ** kwargs ) -> Iterator [ list ] : with hold ( model , * args , ** kwargs ) as events : try : yield events except Exception as error : if undo is not None : with mute ( model ) : undo ( model , tuple ( events ) , error ) events . clear ( ) ra... | Withold events if an error occurs . |
35,446 | def mute ( model : Model ) : if not isinstance ( model , Model ) : raise TypeError ( "Expected a Model, not %r." % model ) restore = model . __dict__ . get ( "_notify_model_views" ) model . _notify_model_views = lambda e : None try : yield finally : if restore is None : del model . _notify_model_views else : model . _n... | Block a model s views from being notified . |
35,447 | def expose ( * methods ) : def setup ( base ) : return expose_as ( base . __name__ , base , * methods ) return setup | A decorator for exposing the methods of a class . |
35,448 | def expose_as ( name , base , * methods ) : classdict = { } for method in methods : if not hasattr ( base , method ) : raise AttributeError ( "Cannot expose '%s', because '%s' " "instances lack this method" % ( method , base . __name__ ) ) else : classdict [ method ] = MethodSpectator ( getattr ( base , method ) , meth... | Return a new type with certain methods that are exposed to callback registration . |
35,449 | def callback ( self , name , before = None , after = None ) : if isinstance ( name , ( list , tuple ) ) : for name in name : self . callback ( name , before , after ) else : if not isinstance ( getattr ( self . subclass , name ) , MethodSpectator ) : raise ValueError ( "No method specator for '%s'" % name ) if before i... | Add a callback pair to this spectator . |
35,450 | def remove_callback ( self , name , before = None , after = None ) : if isinstance ( name , ( list , tuple ) ) : for name in name : self . remove_callback ( name , before , after ) elif before is None and after is None : del self . _callback_registry [ name ] else : if name in self . _callback_registry : callback_list ... | Remove a beforeback and afterback pair from this Spectator |
35,451 | def call ( self , obj , name , method , args , kwargs ) : if name in self . _callback_registry : beforebacks , afterbacks = zip ( * self . _callback_registry . get ( name , [ ] ) ) hold = [ ] for b in beforebacks : if b is not None : call = Data ( name = name , kwargs = kwargs . copy ( ) , args = args ) v = b ( obj , c... | Trigger a method along with its beforebacks and afterbacks . |
35,452 | def cut_to_length ( text , length , delim ) : cut = text . find ( delim , length ) if cut > - 1 : return text [ : cut ] else : return text | Shorten given text on first delimiter after given number of characters . |
35,453 | def get_interpreter_path ( version = None ) : if version and version != str ( sys . version_info [ 0 ] ) : return settings . PYTHON_INTERPRETER + version else : return sys . executable | Return the executable of a specified or current version . |
35,454 | def pypi_metadata_extension ( extraction_fce ) : def inner ( self , client = None ) : data = extraction_fce ( self ) if client is None : logger . warning ( "Client is None, it was probably disabled" ) data . update_attr ( 'source0' , self . archive . name ) return data try : release_data = client . release_data ( self ... | Extracts data from PyPI and merges them with data from extraction method . |
35,455 | def venv_metadata_extension ( extraction_fce ) : def inner ( self ) : data = extraction_fce ( self ) if virtualenv is None or not self . venv : logger . debug ( "Skipping virtualenv metadata extraction." ) return data temp_dir = tempfile . mkdtemp ( ) try : extractor = virtualenv . VirtualEnv ( self . name , temp_dir ,... | Extracts specific metadata from virtualenv object merges them with data from given extraction method . |
35,456 | def process_description ( description_fce ) : def inner ( description ) : clear_description = re . sub ( r'\s+' , ' ' , re . sub ( r'\w+:\/{2}[\d\w-]+(\.[\d\w-]+)*(?:(?:\/[^\s/]*))*' , '' , re . sub ( '(#|=|---|~|`)*' , '' , re . sub ( '((\r?\n)|^).{0,8}((\r?\n)|$)' , '' , re . sub ( '((\r*.. image::|:target:) https?|(... | Removes special character delimiters titles and wraps paragraphs . |
35,457 | def versions_from_archive ( self ) : py_vers = versions_from_trove ( self . classifiers ) return [ ver for ver in py_vers if ver != self . unsupported_version ] | Return Python versions extracted from trove classifiers . |
35,458 | def srcname ( self ) : if self . rpm_name or self . name . startswith ( ( 'python-' , 'Python-' ) ) : return self . name_convertor . base_name ( self . rpm_name or self . name ) | Return srcname for the macro if the pypi name should be changed . |
35,459 | def runtime_deps ( self ) : install_requires = self . metadata [ 'install_requires' ] if self . metadata [ 'entry_points' ] and 'setuptools' not in install_requires : install_requires . append ( 'setuptools' ) return sorted ( self . name_convert_deps_list ( deps_from_pyp_format ( install_requires , runtime = True ) ) ) | Returns list of runtime dependencies of the package specified in setup . py . |
35,460 | def build_deps ( self ) : build_requires = self . metadata [ 'setup_requires' ] if self . has_test_suite : build_requires += self . metadata [ 'tests_require' ] + self . metadata [ 'install_requires' ] if 'setuptools' not in build_requires : build_requires . append ( 'setuptools' ) return sorted ( self . name_convert_d... | Same as runtime_deps but build dependencies . Test and install requires are included if package contains test suite to prevent %check phase crashes because of missing dependencies |
35,461 | def data_from_archive ( self ) : archive_data = super ( SetupPyMetadataExtractor , self ) . data_from_archive archive_data [ 'has_packages' ] = self . has_packages archive_data [ 'packages' ] = self . packages archive_data [ 'has_bundled_egg_info' ] = self . has_bundled_egg_info sphinx_dir = self . sphinx_dir if sphinx... | Appends setup . py specific metadata to archive_data . |
35,462 | def get_requires ( self , requires_types ) : if not isinstance ( requires_types , list ) : requires_types = list ( requires_types ) extracted_requires = [ ] for requires_name in requires_types : for requires in self . json_metadata . get ( requires_name , [ ] ) : if 'win' in requires . get ( 'environment' , { } ) : con... | Extracts requires of given types from metadata file filter windows specific requires . |
35,463 | def get_url ( client , name , version , wheel = False , hashed_format = False ) : try : release_urls = client . release_urls ( name , version ) release_data = client . release_data ( name , version ) except BaseException : logger . debug ( 'Client: {0} Name: {1} Version: {2}.' . format ( client , name , version ) ) rai... | Retrieves list of package URLs using PyPI s XML - RPC . Chooses URL of prefered archive and md5_digest . |
35,464 | def fill ( self , path ) : self . bindir = set ( os . listdir ( path + 'bin/' ) ) self . lib_sitepackages = set ( os . listdir ( glob . glob ( path + 'lib/python?.?/site-packages/' ) [ 0 ] ) ) | Scans content of directories |
35,465 | def install_package_to_venv ( self ) : try : self . env . install ( self . name , force = True , options = [ "--no-deps" ] ) except ( ve . PackageInstallationException , ve . VirtualenvReadonlyException ) : raise VirtualenvFailException ( 'Failed to install package to virtualenv' ) self . dirs_after_install . fill ( se... | Installs package given as first argument to virtualenv without dependencies |
35,466 | def get_dirs_differance ( self ) : try : diff = self . dirs_after_install - self . dirs_before_install except ValueError : raise VirtualenvFailException ( "Some of the DirsContent attributes is uninicialized" ) self . data [ 'has_pth' ] = any ( [ x for x in diff . lib_sitepackages if x . endswith ( '.pth' ) ] ) site_pa... | Makes final versions of site_packages and scripts using DirsContent sub method and filters |
35,467 | def main ( package , v , d , s , r , proxy , srpm , p , b , o , t , venv , autonc , sclize , ** scl_kwargs ) : register_file_log_handler ( '/tmp/pyp2rpm-{0}.log' . format ( getpass . getuser ( ) ) ) if srpm or s : register_console_log_handler ( ) distro = o if t and os . path . splitext ( t ) [ 0 ] in settings . KNOWN_... | Convert PyPI package to RPM specfile or SRPM . |
35,468 | def convert_to_scl ( spec , scl_options ) : scl_options [ 'skip_functions' ] = scl_options [ 'skip_functions' ] . split ( ',' ) scl_options [ 'meta_spec' ] = None convertor = SclConvertor ( options = scl_options ) return str ( convertor . convert ( spec ) ) | Convert spec into SCL - style spec file using spec2scl . |
35,469 | def format_options ( self , ctx , formatter ) : super ( Pyp2rpmCommand , self ) . format_options ( ctx , formatter ) scl_opts = [ ] for param in self . get_params ( ctx ) : if isinstance ( param , SclizeOption ) : scl_opts . append ( param . get_scl_help_record ( ctx ) ) if scl_opts : with formatter . section ( 'SCL re... | Writes SCL related options into the formatter as a separate group . |
35,470 | def handle_parse_result ( self , ctx , opts , args ) : if 'sclize' in opts and not SclConvertor : raise click . UsageError ( "Please install spec2scl package to " "perform SCL-style conversion" ) if self . name in opts and 'sclize' not in opts : raise click . UsageError ( "`--{}` can only be used with --sclize option" ... | Validate SCL related options before parsing . |
35,471 | def to_list ( var ) : if var is None : return [ ] if isinstance ( var , str ) : var = var . split ( '\n' ) elif not isinstance ( var , list ) : try : var = list ( var ) except TypeError : raise ValueError ( "{} cannot be converted to the list." . format ( var ) ) return var | Checks if given value is a list tries to convert if it is not . |
35,472 | def run ( self ) : if self . stdout : sys . stdout . write ( "extracted json data:\n" + json . dumps ( self . metadata , default = to_str ) + "\n" ) else : extract_dist . class_metadata = self . metadata | Sends extracted metadata in json format to stdout if stdout option is specified assigns metadata dictionary to class_metadata variable otherwise . |
35,473 | def get_changelog_date_packager ( self ) : try : packager = subprocess . Popen ( 'rpmdev-packager' , stdout = subprocess . PIPE ) . communicate ( ) [ 0 ] . strip ( ) except OSError : packager = "John Doe <john@doe.com>" logger . warn ( "Package rpmdevtools is missing, using default " "name: {0}." . format ( packager ) ... | Returns part of the changelog entry containing date and packager . |
35,474 | def run ( self ) : with utils . ChangeDir ( self . dirname ) : sys . path . insert ( 0 , self . dirname ) sys . argv [ 1 : ] = self . args runpy . run_module ( self . not_suffixed ( self . filename ) , run_name = '__main__' , alter_sys = True ) | Executes the code of the specified module . |
35,475 | def run ( self , interpreter ) : with utils . ChangeDir ( self . dirname ) : command_list = [ 'PYTHONPATH=' + main_dir , interpreter , self . filename ] + list ( self . args ) try : proc = Popen ( ' ' . join ( command_list ) , stdout = PIPE , stderr = PIPE , shell = True ) stream_data = proc . communicate ( ) except Ex... | Executes the code of the specified module . Deserializes captured json data . |
35,476 | def generator_to_list ( fn ) : def wrapper ( * args , ** kw ) : return list ( fn ( * args , ** kw ) ) return wrapper | This decorator is for flat_list function . It converts returned generator to list . |
35,477 | def get_content_of_file ( self , name , full_path = False ) : if self . handle : for member in self . handle . getmembers ( ) : if ( full_path and member . name == name ) or ( not full_path and os . path . basename ( member . name ) == name ) : extracted = self . handle . extractfile ( member ) return extracted . read ... | Returns content of file from archive . |
35,478 | def extract_file ( self , name , full_path = False , directory = "." ) : if self . handle : for member in self . handle . getmembers ( ) : if ( full_path and member . name == name or not full_path and os . path . basename ( member . name ) == name ) : self . handle . extract ( member , path = directory ) | Extract a member from the archive to the specified working directory . Behaviour of name and pull_path is the same as in function get_content_of_file . |
35,479 | def extract_all ( self , directory = "." , members = None ) : if self . handle : self . handle . extractall ( path = directory , members = members ) | Extract all member from the archive to the specified working directory . |
35,480 | def get_files_re ( self , file_re , full_path = False , ignorecase = False ) : try : if ignorecase : compiled_re = re . compile ( file_re , re . I ) else : compiled_re = re . compile ( file_re ) except sre_constants . error : logger . error ( "Failed to compile regex: {}." . format ( file_re ) ) return [ ] found = [ ] ... | Finds all files that match file_re and returns their list . Doesn t return directories only files . |
35,481 | def get_directories_re ( self , directory_re , full_path = False , ignorecase = False ) : if ignorecase : compiled_re = re . compile ( directory_re , re . I ) else : compiled_re = re . compile ( directory_re ) found = set ( ) if self . handle : for member in self . handle . getmembers ( ) : if isinstance ( member , Zip... | Same as get_files_re but for directories |
35,482 | def top_directory ( self ) : if self . handle : return os . path . commonprefix ( self . handle . getnames ( ) ) . rstrip ( '/' ) | Return the name of the archive topmost directory . |
35,483 | def base_name ( self , name ) : base_name = name . replace ( '.' , "-" ) found_prefix = self . reg_start . search ( name ) if found_prefix : base_name = found_prefix . group ( 2 ) found_end = self . reg_end . search ( name . lower ( ) ) if found_end : base_name = found_end . group ( 1 ) return base_name | Removes any python prefixes of suffixes from name if present . |
35,484 | def merge ( self , other ) : if not isinstance ( other , NameVariants ) : raise TypeError ( "NameVariants isinstance can be merge with" "other isinstance of the same class" ) for key in self . variants : self . variants [ key ] = self . variants [ key ] or other . variants [ key ] return self | Merges object with other NameVariants object not set values of self . variants are replace by values from other object . |
35,485 | def merge_versions ( self , data ) : if self . template == "epel6.spec" : requested_versions = self . python_versions if self . base_python_version : requested_versions += [ self . base_python_version ] if any ( int ( ver [ 0 ] ) > 2 for ver in requested_versions ) : sys . stderr . write ( "Invalid version, major numbe... | Merges python versions specified in command lines options with extracted versions checks if some of the versions is not > 2 if EPEL6 template will be used . attributes base_python_version and python_versions contain values specified by command line options or default values data . python_versions contains extracted dat... |
35,486 | def getter ( self ) : if not hasattr ( self , '_getter' ) : if not self . pypi : self . _getter = package_getters . LocalFileGetter ( self . package , self . save_dir ) else : logger . debug ( '{0} does not exist as local file trying PyPI.' . format ( self . package ) ) self . _getter = package_getters . PypiDownloader... | Returns an instance of proper PackageGetter subclass . Always returns the same instance . |
35,487 | def metadata_extractor ( self ) : if not hasattr ( self , '_local_file' ) : raise AttributeError ( "local_file attribute must be set before " "calling metadata_extractor" ) if not hasattr ( self , '_metadata_extractor' ) : if self . local_file . endswith ( '.whl' ) : logger . info ( "Getting metadata from wheel using "... | Returns an instance of proper MetadataExtractor subclass . Always returns the same instance . |
35,488 | def client ( self ) : if self . proxy : proxyhandler = urllib . ProxyHandler ( { "http" : self . proxy } ) opener = urllib . build_opener ( proxyhandler ) urllib . install_opener ( opener ) transport = ProxyTransport ( ) if not hasattr ( self , '_client' ) : transport = None if self . pypi : if self . proxy : logger . ... | XMLRPC client for PyPI . Always returns the same instance . |
35,489 | def memoize_by_args ( func ) : memory = { } @ functools . wraps ( func ) def memoized ( * args ) : if args not in memory . keys ( ) : value = func ( * args ) memory [ args ] = value return memory [ args ] return memoized | Memoizes return value of a func based on args . |
35,490 | def build_srpm ( specfile , save_dir ) : logger . info ( 'Starting rpmbuild to build: {0} SRPM.' . format ( specfile ) ) if save_dir != get_default_save_path ( ) : try : msg = subprocess . Popen ( [ 'rpmbuild' , '--define' , '_sourcedir {0}' . format ( save_dir ) , '--define' , '_builddir {0}' . format ( save_dir ) , '... | Builds a srpm from given specfile using rpmbuild . Generated srpm is stored in directory specified by save_dir . |
35,491 | def remove_major_minor_suffix ( scripts ) : minor_major_regex = re . compile ( "-\d.?\d?$" ) return [ x for x in scripts if not minor_major_regex . search ( x ) ] | Checks if executables already contain a - MAJOR . MINOR suffix . |
35,492 | def runtime_to_build ( runtime_deps ) : build_deps = copy . deepcopy ( runtime_deps ) for dep in build_deps : if len ( dep ) > 0 : dep [ 0 ] = 'BuildRequires' return build_deps | Adds all runtime deps to build deps |
35,493 | def unique_deps ( deps ) : deps . sort ( ) return list ( k for k , _ in itertools . groupby ( deps ) ) | Remove duplicities from deps list of the lists |
35,494 | def c_time_locale ( ) : old_time_locale = locale . getlocale ( locale . LC_TIME ) locale . setlocale ( locale . LC_TIME , 'C' ) yield locale . setlocale ( locale . LC_TIME , old_time_locale ) | Context manager with C LC_TIME locale |
35,495 | def rpm_eval ( macro ) : try : value = subprocess . Popen ( [ 'rpm' , '--eval' , macro ] , stdout = subprocess . PIPE ) . communicate ( ) [ 0 ] . strip ( ) except OSError : logger . error ( 'Failed to get value of {0} rpm macro' . format ( macro ) , exc_info = True ) value = b'' return console_to_str ( value ) | Get value of given macro using rpm tool |
35,496 | def get_default_save_path ( ) : macro = '%{_topdir}' if rpm : save_path = rpm . expandMacro ( macro ) else : save_path = rpm_eval ( macro ) if not save_path : logger . warn ( "rpm tools are missing, using default save path " "~/rpmbuild/." ) save_path = os . path . expanduser ( '~/rpmbuild' ) return save_path | Return default save path for the packages |
35,497 | def check_and_get_data ( input_list , ** pars ) : empty_list = [ ] retrieve_list = [ ] candidate_list = [ ] ipppssoot_list = [ ] total_input_list = [ ] for input_item in input_list : print ( 'Input item: ' , input_item ) indx = input_item . find ( '_' ) if indx != - 1 : lc_input_item = input_item . lower ( ) suffix = l... | Verify that all specified files are present . If not retrieve them from MAST . |
35,498 | def perform_align ( input_list , ** kwargs ) : filteredTable = Table ( ) run_align ( input_list , result = filteredTable , ** kwargs ) return filteredTable | Main calling function . |
35,499 | def generate_astrometric_catalog ( imglist , ** pars ) : temp_pars = pars . copy ( ) if pars [ 'output' ] == True : pars [ 'output' ] = 'ref_cat.ecsv' else : pars [ 'output' ] = None out_catalog = amutils . create_astrometric_catalog ( imglist , ** pars ) pars = temp_pars . copy ( ) if len ( out_catalog ) > 0 and pars ... | Generates a catalog of all sources from an existing astrometric catalog are in or near the FOVs of the images in the input list . |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.