Setter for _segment_file attribute
354163
def segment_file(self, value):
        
        assert os.path.isfile(value), "%s is not a valid file" % value
        self._segment_file = value
1051385
def _set_attribute(self, attribute, name, value):
        """"""
        try:
            if attribute is None:
                attribute = self._attribute_file_open( name )
            else:
                attribute.seek(0)

            if isinstance(value, str):
                value = value.encode()
            attribute.write(value)
            attribute.flush()
        except Exception as ex:
            self._raise_friendly_access_error(ex, name)
        return attribute
1172938
def Initialize(self):
    """"""
    super(AFF4ImageBase, self).Initialize()
    self.offset = 0
    # A cache for segments.
    self.chunk_cache = ChunkCache(self._WriteChunk, 100)

    if "r" in self.mode:
      self.size = int(self.Get(self.Schema.SIZE))
      # pylint: disable=protected-access
      self.chunksize = int(self.Get(self.Schema._CHUNKSIZE))
      # pylint: enable=protected-access
      self.content_last = self.Get(self.Schema.CONTENT_LAST)
    else:
      self.size = 0
      self.content_last = None
255768
private static void setSectionParameters(Section section,
			Properties attributes) {
		String value;
		value = attributes.getProperty(ElementTags.NUMBERDEPTH);
		if (value != null) {
			section.setNumberDepth(Integer.parseInt(value));
		}
		value = attributes.getProperty(ElementTags.INDENT);
		if (value != null) {
			section.setIndentation(Float.parseFloat(value + "f"));
		}
		value = attributes.getProperty(ElementTags.INDENTATIONLEFT);
		if (value != null) {
			section.setIndentationLeft(Float.parseFloat(value + "f"));
		}
		value = attributes.getProperty(ElementTags.INDENTATIONRIGHT);
		if (value != null) {
			section.setIndentationRight(Float.parseFloat(value + "f"));
		}
	}
1183604
def to_segment_xml(self, override_file_if_exists=False):
        
        # create XML doc and add process table
        outdoc = ligolw.Document()
        outdoc.appendChild(ligolw.LIGO_LW())
        process = ligolw_process.register_to_xmldoc(outdoc, sys.argv[0], {})

        for key, seglist in self.segment_dict.items():
            ifo, name = self.parse_segdict_key(key)
            # Ensure we have LIGOTimeGPS
            fsegs = [(lal.LIGOTimeGPS(seg[0]),
                      lal.LIGOTimeGPS(seg[1])) for seg in seglist]

            if self.seg_summ_dict is None:
                vsegs = [(lal.LIGOTimeGPS(seg[0]),
                          lal.LIGOTimeGPS(seg[1])) \
                         for seg in self.valid_segments]
            else:
                vsegs = [(lal.LIGOTimeGPS(seg[0]),
                          lal.LIGOTimeGPS(seg[1])) \
                         for seg in self.seg_summ_dict[key]]

            # Add using glue library to set all segment tables
            with ligolw_segments.LigolwSegments(outdoc, process) as x:
                x.add(ligolw_segments.LigolwSegmentList(active=fsegs,
                                    instruments=set([ifo]), name=name,
                                    version=1, valid=vsegs))

        # write file
        url = urlparse.urljoin('file:', urllib.pathname2url(self.storage_path))
        if not override_file_if_exists or not self.has_pfn(url, site='local'):
            self.PFN(url, site='local')
        ligolw_utils.write_filename(outdoc, self.storage_path)
235618
def setStartSegment(self, segment):
        
        segments = self.segments
        if not isinstance(segment, int):
            segmentIndex = segments.index(segment)
        else:
            segmentIndex = segment
        if len(self.segments) < 2:
            return
        if segmentIndex == 0:
            return
        if segmentIndex >= len(segments):
            raise ValueError(("The contour does not contain a segment "
                              "at index %d" % segmentIndex))
        self._setStartSegment(segmentIndex)
57450
private synchronized void resetCurrentSegment() {
    Segment lastSegment = lastSegment();
    if (lastSegment != null) {
      currentSegment = lastSegment;
    } else {
      SegmentDescriptor descriptor = SegmentDescriptor.builder()
        .withId(1)
        .withVersion(1)
        .withIndex(1)
        .withMaxSegmentSize(storage.maxSegmentSize())
        .withMaxEntries(storage.maxEntriesPerSegment())
        .build();
      descriptor.lock();

      currentSegment = createSegment(descriptor);

      segments.put(1L, currentSegment);
    }
  }
406049
private IndexInput openMtasFile(SegmentReadState state, String name,
      String extension, Integer minimum, Integer maximum) throws IOException {
    String fileName = IndexFileNames.segmentFileName(state.segmentInfo.name,
        state.segmentSuffix, extension);
    IndexInput object;
    try {
      object = state.directory.openInput(fileName, state.context);
    } catch (FileNotFoundException | NoSuchFileException e) {
      log.debug(e);
      // throw new NoSuchFileException(e.getMessage());
      return null;
    }
    int minVersion = (minimum == null) ? MtasCodecPostingsFormat.VERSION_START
        : minimum.intValue();
    int maxVersion = (maximum == null) ? MtasCodecPostingsFormat.VERSION_CURRENT
        : maximum.intValue();
    try {
      CodecUtil.checkIndexHeader(object, name, minVersion, maxVersion,
          state.segmentInfo.getId(), state.segmentSuffix);
    } catch (IndexFormatTooOldException e) {
      object.close();
      log.debug(e);
      throw new IndexFormatTooOldException(e.getMessage(), e.getVersion(),
          e.getMinVersion(), e.getMaxVersion());
    } catch (EOFException e) {
      object.close();
      log.debug(e);
      // throw new EOFException(e.getMessage());
      return null;
    }
    return object;
  }
526523
public void setAttribute(File file, String attribute, Object value, boolean create) {
    String view = getViewName(attribute);
    String attr = getSingleAttribute(attribute);
    setAttributeInternal(file, view, attr, value, create);
  }
327933
def _allocate_specified_segment(self, session, seg_id, source):
        
        try:
            with session.begin(subtransactions=True):
                alloc = (session.query(self.model).filter_by(
                    segmentation_id=seg_id).first())
                if alloc:
                    if alloc.allocated:
                        # Segment already allocated
                        return
                    else:
                        # Segment not allocated
                        count = (session.query(self.model).
                                 filter_by(allocated=False,
                                           segmentation_id=seg_id).update(
                                               {"allocated": True}))
                        if count:
                            return alloc

                # Segment to create or already allocated
                alloc = self.model(segmentation_id=seg_id,
                                   allocated=True, source=source)
                session.add(alloc)

        except db_exc.DBDuplicateEntry:
            # Segment already allocated (insert failure)
            alloc = None

        return alloc
667270
private Segment createMappedSegment(SegmentDescriptor descriptor) {
    File segmentFile = SegmentFile.createSegmentFile(name, storage.directory(), descriptor.id(), descriptor.version());
    Buffer buffer = MappedBuffer.allocate(segmentFile, Math.min(DEFAULT_BUFFER_SIZE, descriptor.maxSegmentSize()), Integer.MAX_VALUE);
    descriptor.copyTo(buffer);
    Segment segment = new Segment(new SegmentFile(segmentFile), buffer.slice(), descriptor, createIndex(descriptor), new OffsetPredicate(), serializer.clone(), this);
    LOGGER.debug("Created segment: {}", segment);
    return segment;
  }
195817
def set_attribute(file, element, key, value):
    '''
    
    '''
    try:
        root = ET.parse(file)
        element = root.find(element)
    except AttributeError:
        log.error("Unable to find element matching %s", element)
        return False
    element.set(key, str(value))
    root.write(file)
    return True
166667
def set_job_desc(segments, max_files)
      if segments.count > 0
        crawl_name = segments[0].crawl.crawl_name if segments[0].crawl.present?
        file_desc = max_files.nil? ? 'all files' : "#{max_files} files per segment"
      end

      "Crawl: #{crawl_name} Segments: #{segments.count} Parsing: #{file_desc}"
    end
990972
def SetFileContext(self, file_name, row_num, row, headers):
    
    self._context = (file_name, row_num, row, headers)
734416
def _write_segments(self, filename):
        
        # Column headers
        shead = '\t'.join(['id', 'multiplicon', 'genome', 'list', 'first',
                           'last', 'order'])
        with open(filename, 'w') as fhandle:
            fhandle.write(shead + '\n')
            for mrow in self.segments:
                fhandle.write('\t'.join([str(e) for e in mrow]) + '\n')
362321
def set_int_attribute(self, target, display_mask, attr, value):
    """"""
    reply = NVCtrlSetAttributeAndGetStatusReplyRequest(display=self.display,
                                                       opcode=self.display.get_extension_major(extname),
                                                       target_id=target.id(),
                                                       target_type=target.type(),
                                                       display_mask=display_mask,
                                                       attr=attr,
                                                       value=value)
    return reply._data.get('flags') != 0
485435
public static final void setIntAttribute(Path path, String attribute, int value, LinkOption... options) throws IOException
    {
        attribute = attribute.startsWith("user:") ? attribute : "user:"+attribute;
        Files.setAttribute(path, attribute, Primitives.writeInt(value), options);
    }