retrieve the PlayerRecord settings from saved disk file
173516
def load(self, playerName=None):
        """"""
        if playerName: # switch the PlayerRecord this object describes
            self.name = playerName # preset value to load self.filename
        try:
            with open(self.filename, "rb") as f:
                data = f.read()
        except Exception:
            raise ValueError("invalid profile, '%s'. file does not exist: %s"%(self.name, self.filename))
        self.update(json.loads(data))
        self._matches = [] # mandate match history be recalculated for this newly loaded player
1260377
def record_to_objects(self):
        """"""
        from ..util import AttrDict

        fr = self.record

        contents = fr.unpacked_contents

        if not contents:
            return

        ad = AttrDict(contents)


        # Get time that filessystem was synchronized to the File record.
        # Maybe use this to avoid overwriting configs that changed by bundle program.
        # fs_sync_time = self._dataset.config.sync[self.file_const][self.file_to_record]

        self._dataset.config.metadata.set(ad)

        self._dataset._database.commit()

        return ad
480448
def get_saved_rules(conf_file=None):
    '''
    

    '''
    if _conf() and not conf_file:
        conf_file = _conf()

    with salt.utils.files.fopen(conf_file) as fp_:
        lines = salt.utils.data.decode(fp_.readlines())
    rules = []
    for line in lines:
        tmpline = line.strip()
        if not tmpline:
            continue
        if tmpline.startswith('#'):
            continue
        rules.append(line)
    return rules
471602
function _getSavedBytes(rawFile, compressedFile) {
    var savedBytes = rawFile.size - compressedFile.size;

    if (savedBytes > 0) return savedBytes;

    return 0;
}
22810
def get_lastfm():
    

    filename = os.path.join(_download.LOCAL_CACHE_DIR, "lastfm_360k.hdf5")
    if not os.path.isfile(filename):
        log.info("Downloading dataset to '%s'", filename)
        _download.download_file(URL, filename)
    else:
        log.info("Using cached dataset at '%s'", filename)

    with h5py.File(filename, 'r') as f:
        m = f.get('artist_user_plays')
        plays = csr_matrix((m.get('data'), m.get('indices'), m.get('indptr')))
        return np.array(f['artist']), np.array(f['user']), plays
1098203
def record(self):
        

        modules = []
        scripts = []
        if self.get_content_of_file('RECORD'):
            lines = self.get_content_of_file('RECORD').splitlines()
            for line in lines:
                if 'dist-info' in line or '/' not in line:
                    continue
                elif '.data/scripts' in line:
                    script = line.split(',', 1)[0]
                    # strip Name.version.data/scripts/
                    scripts.append(re.sub('.*/.*/', '', script))
                else:
                    # strip everything from first occurance of slash
                    modules.append(re.sub('/.*', '', line))

        return {'modules': sorted(set(modules)),
                'scripts': sorted(set(scripts))}
101673
def recording_settings(self):
        
        if self._recording_settings is None:
            self._recording_settings = RecordingSettingsList(self)
        return self._recording_settings
1333282
def settings(self):
        """"""
        _settings = {
            'action': self._action,
            # not supported in v2 batch
            # 'attributeWriteType': self._attribute_write_type,
            'attributeWriteType': 'Replace',
            'haltOnError': str(self._halt_on_error).lower(),
            'owner': self._owner,
            'version': 'V2',
        }
        if self._playbook_triggers_enabled is not None:
            _settings['playbookTriggersEnabled'] = str(self._playbook_triggers_enabled).lower()
        if self._hash_collision_mode is not None:
            _settings['hashCollisionMode'] = self._hash_collision_mode
        if self._file_merge_mode is not None:
            _settings['fileMergeMode'] = self._file_merge_mode
        return _settings
600608
def save_settings(self, settings_file):
        """"""
        settings = {}
        for parameter in self.parameter_maxima:
            settings[parameter] = self.__getattribute__(parameter)
        with open(settings_file, "w") as settings_file:
            simplejson.dump(settings, settings_file)
186648
def _replay_index(replay_dir):
  """"""
  run_config = run_configs.get()
  replay_dir = run_config.abs_replay_path(replay_dir)
  print("Checking: ", replay_dir)

  with run_config.start(want_rgb=False) as controller:
    print("-" * 60)
    print(",".join((
        "filename",
        "build",
        "map_name",
        "game_duration_loops",
        "players",
        "P1-outcome",
        "P1-race",
        "P1-apm",
        "P2-race",
        "P2-apm",
    )))

    try:
      bad_replays = []
      for file_path in run_config.replay_paths(replay_dir):
        file_name = os.path.basename(file_path)
        try:
          info = controller.replay_info(run_config.replay_data(file_path))
        except remote_controller.RequestError as e:
          bad_replays.append("%s: %s" % (file_name, e))
          continue
        if info.HasField("error"):
          print("failed:", file_name, info.error, info.error_details)
          bad_replays.append(file_name)
        else:
          out = [
              file_name,
              info.base_build,
              info.map_name,
              info.game_duration_loops,
              len(info.player_info),
              sc_pb.Result.Name(info.player_info[0].player_result.result),
              sc_common.Race.Name(info.player_info[0].player_info.race_actual),
              info.player_info[0].player_apm,
          ]
          if len(info.player_info) >= 2:
            out += [
                sc_common.Race.Name(
                    info.player_info[1].player_info.race_actual),
                info.player_info[1].player_apm,
            ]
          print(u",".join(str(s) for s in out))
    except KeyboardInterrupt:
      pass
    finally:
      if bad_replays:
        print("\n")
        print("Replays with errors:")
        print("\n".join(bad_replays))
1050263
def __read_lipd_contents():
    
    global files, settings
    _d = {}
    try:
        if len(files[".lpd"]) == 1:
            _d = lipd_read(files[".lpd"][0]["full_path"])
            if settings["verbose"]:
                print("Finished read: 1 record")
        else:
            for file in files[".lpd"]:
                _d[file["filename_no_ext"]] = lipd_read(file["full_path"])
            if settings["verbose"]:
                print("Finished read: {} records".format(len(_d)))
    except Exception as e:
        print("Error: read_lipd_contents: {}".format(e))
    return _d
321669
def options(self, parser, env=os.environ):
        ""
        parser.add_option("--%s-record" % self.name,
                          action="store",
                          metavar="FILE",
                          dest="record_filename",
                          help="Record actions to this file.")
        parser.add_option("--%s-playback" % self.name,
                          action="store",
                          metavar="FILE",
                          dest="playback_filename",
                          help="Playback actions from this file.")
1034285
function readRecord() {
    if (index >= text.length) {
      return EOF;
    }
    var record = [];
    for (var field = readField(); field != EOR; field = readField()) {
      record.push(field);
    }
    return record;
  }
684924
def save(self, new=None, timeout=2):
        """"""
        if new: self.update(new) # allow two operations (update + save) with a single command
        if not self._updated: return # nothing to do
        thisPkg = os.path.dirname(__file__)
        filename = os.path.join(thisPkg, c.FOLDER_JSON, c.FILE_GAME_VERSIONS)
        fParts = c.FILE_GAME_VERSIONS.split('.')
        newFile = os.path.join(thisPkg, c.FOLDER_JSON, "%s_%s.%s"%(fParts[0], dateFormat.now(), fParts[1]))
        if not os.path.isfile(newFile):
            #fParts = c.FILE_GAME_VERSIONS.split('.')
            #newFile = "%s%s%s_%s.%s"%(c.FOLDER_JSON, os.sep, fParts[0], dateFormat.now(), fParts[1])
            #if not os.path.isfile(newFile):
            #print(filename)
            #print(newFile)
            os.rename(filename, newFile) # backup existing version file
        recordKeys = [(record["version"], record) for record in Handler.ALL_VERS_DATA.values()]
        data = [r for k,r in sorted(recordKeys)] # i.e. get values sorted by version key
        start = time.time()
        while time.time()-start < timeout: # allow multiple retries if multiple processes fight over the version file
            try:
                with open(filename, "wb") as f:
                    f.write(str.encode(json.dumps(data, indent=4, sort_keys=True))) # python3 requires encoding str => bytes to write to file
                self._updated = False
                return
            except IOError: pass # continue waiting for file to be available
        raise # after timeout, prior exception is what matters
419304
public Record getRecord(String strFileName)
    {
        if (m_vRecordList == null)
            return null;
        Record record = m_vRecordList.getRecord(strFileName);
        if (record != null)
            return record;
        return super.getRecord(strFileName);    // Look thru the parent window now
    }
261604
public Record getRecord(String strFileName)
    {
        if (m_screenParent != null)
            return m_screenParent.getRecord(strFileName); // Look thru the parent window now
        else
            return null;
    }
863871
def parse_match_settings(match_settings, config: ConfigObject):
    

    match_settings.game_mode = config.get(MATCH_CONFIGURATION_HEADER, GAME_MODE)
    match_settings.game_map = config.get(MATCH_CONFIGURATION_HEADER, GAME_MAP)
    match_settings.skip_replays = config.getboolean(MATCH_CONFIGURATION_HEADER, SKIP_REPLAYS)
    match_settings.instant_start = config.getboolean(MATCH_CONFIGURATION_HEADER, INSTANT_START)

    parse_mutator_settings(match_settings.mutators, config)